You can factory reset a PlayStation 4 from your console's dashboard and via safe mode on your console.
You should deactivate your PS4 so it's no longer associated with your account if you are selling or giving it away.