Hi there, you can factory reset your Mac running macOS Yosemite by booting it into macOS Recovery mode. But before you factory reset your Mac, you need to wipe the startup disk first.
Step 1: Boot into macOS Recovery mode
Here are how to boot your Mac into macOS Recovery mode:
For Intel-based Mac: Restart your Mac and hold down Command + R keys simultaneously. Release the keys until you see an Apple logo and your Mac will boot into the macOS Utilities window in the recovery partition.
For Apple Silicon Mac: Shut down your Mac completely, press the Touch ID button to turn it on, and then immediately press down the Touch ID button until you see "Loading startup options". Click Options and then click Continue to boot in macOS Recovery.
Step 2: Erase the Startup disk
1. Select Disk Utility from the main menu and click on the Continue button.
2. After DU loads select your startup volume (usually Macintosh HD) from the left side list. Click on the Erase tab in the DU main window.
3. Set the format type to Mac OS Extended (Journaled.) Optionally, click on the Security button and set the Zero Data option to one-pass. Click on the Erase button and wait until the process has been completed.
4. Quit DU and return to the main menu.
Step 3: Reinstall macOS
1. Select Reinstall macOS in the macOS Utilities window in Recovery Mode.
2. Follow the onscreen instructions to install a fresh copy of macOS on your Mac.