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.
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.