Yes, it is possible to wipe the iPhone completely before selling it. Here are the steps you can follow:
Backup your iPhone: How to wipe the iPhone completely before selling it, make sure to backup your data to iCloud or a computer through iTunes. This will allow you to transfer your data to a new iPhone or retrieve it if needed later.
Turn off Find My iPhone: You will need to turn off Find My iPhone if you enabled it on the iPhone you're selling. Go to Settings > [Your Name] > iCloud > Find My iPhone, then turn off the option to Find My iPhone.
Sign out of iCloud and other accounts: You should sign out of your iCloud account, iTunes, App Store, and any other accounts that you're signed in to on your iPhone. To do this, go to Settings > [Your Name] > iTunes & App Store, then tap your Apple ID and sign out. Next, go to Settings > [Your Name] > iCloud, then scroll down and tap Sign Out.
Wipe all content and settings on your iPhone: This is the most important step in wiping your iPhone completely. Go to Settings > General > Reset > Erase All Content and Settings. Enter your passcode (if you have one) and then tap Erase iPhone. You may have to enter your Apple ID and password to finish the process.
Wait for the erasure process to complete: After you've initiated the erase process, you'll need to wait for it to complete before your iPhone is completely wiped.
Once you've completed these steps, your iPhone will be wiped of all your personal data and settings. You can then sell your iPhone with confidence that your data will not be accessible to anyone else.