If you want to install the most recent version of macOS which is compatible with your Mac, then boot into Internet Recovery Mode using Command + Option + R. Unfortunately sometimes even this special key combination will still only boot to the online macOS installer for the version of macOS which originally shipped with the Mac which in your case appears to be Yosemite.
If you are reinstalling macOS Yosemite, make sure to correctly partition & format the whole physical drive as described in this article:
https://eshop.macsales.com/tech_center/formatting/Mac_Formatting_6-10_R3.pdf
If you are installing macOS 10.13+, then you will need the "View" "Show All Devices" option in Disk Utility as mentioned by @a brody in order to see the physical drive which should be erased (different than with Yosemite which need to use the "partition" tab) as GUID partition and APFS (top option).
When you sell a computer you should have no user accounts on the computer, but instead leave the computer so that Setup Assistant will run the first time the new owner boots the computer so the new owner can set it up just like you did when you purchased it new from Apple. Here is an Apple article on how to prepare a Mac for sale:
What to do before you sell, give away, or trade in your Mac - Apple Support
If you want to upgrade Yosemite to a later version of macOS, then create a bootable macOS USB installer using the instructions in this Apple article:
Create a bootable installer for macOS - Apple Support
If you use the bootable macOS USB installer, then you can once more erase the whole physical drive to perform a clean install. You should not be prompted for your AppleID or password when downloading the macOS installers using the links in the article above. You can also use the command line to manually download any macOS installer which is available for your specific Mac by using the instructions in the following article (definitely won't require an AppleID):
https://macreports.com/how-to-download-macos-installers-using-terminal/