Back up any files you want to keep
Sign out of iCloud, iMessage, and other accounts
Unpair Bluetooth devices if needed
Restart the Mac and enter Recovery Mode
Open Disk Utility
Erase the startup disk
Quit Disk Utility
Choose Reinstall macOS
Follow the on-screen setup or shut down if selling the Mac
If needed, use Find My to remove the Mac from your Apple ID account
