Apple - Will an iOS reinstall make a jailbroken iOS device "unjailbroken" and “supported by Apple” again?
Apple cannot tell if you've previously been jailbroken if you do a full restore. Apple has a tutorial on how to do this (support article HT201252).
Jailbreaking only affects the software, and restoring a jailbroken device to an official version of the iOS firmware will make your device "not jailbroken." Doing a full restore can be done to any device regardless of whether or not they are currently or have previously been jailbroken.
Doing a full restore will set the device back to factory defaults for that version of iOS. A full restore erases everything including /private/var/
where all your personal data is stored. If you do an update instead of a full restore, data from the jailbreak could be left behind, since an update leaves files from the previous version.
Additional Information
There is one part of an iOS device called the NVRAM that persists even across a full restore. The NVRAM contains environment variables that are needed for the device to boot. If you have gone out of your way to make modifications to your NVRAM, it can reveal that you have been jailbroken since these modifications can only be made from a jailbroken state. If you don't know how to make modifications to your NVRAM or you've never heard of NVRAM, then don't worry, this doesn't apply to you.
One word, yes.
Restoring the iPhone (in iTunes) will make it "Not jailbroken".
To avoid trouble and if you want to make sure all residual files are removed I would recommend restoring in DFU mode using the latest iOS firmware and setup the device as a new iPhone after the restore.
I had to use jailbroken iPhones for testing and this worked for me, no application ever complained that the phones are jailbroken after a full restore.
Fwiw. Spoke with an Apple rep at a retail, brick-and-mortar (sort of) Apple Store today. Rep said that he actually worked to confirm a customer's iPhone hardware prob by reinstalling iOS on customer's jailbroken phone, and that it was "totally cool" by him, no known (or at least strict) Apple policy against such a thing.