When you download the InstaMacOSX.dmg for Mac OS X Yosemite
it has to be opened to the InstallMacOSX.pkg, this part you can do on all Macs.
However the next part where you open the InstallMacOSX.pkg and get an installation
window only works on Macs that can actually run Mac OS X Yosemite.
Any Mac like your MBP M1 that came preinstalled with a newer OS refuses to create the
Install OS X Yosemite.app required to make a bootable USB.
Options, find a Mac that you know that can run Yosemite and download Yosemite on it
and then make the bootable USB. This includes Mac that have ran Yosemite but have been
upgraded to a newer OS.
Try this workaround on your MBP M1, https://apple.stackexchange.com/questions/379603/how-do-i-create-el-capitan-installer-on-a-catalina-or-post-el-capitan-installe
This is the Terminal command if you want to create a bootable USB installer for Mac OS X Yosemite,
sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ Yosemite.app
Or if you feel you can only reinstall from Apples Recovery Servers then follow the instructions below.
The certificates for several of Apples OS's expired in October 2019, Apple haven’t bothered getting these updated on
their Recovery Servers with valid certificates.
This may be the problem you are experiencing.
Try this workaround, we are going to set the time and date on your mac to a date previous to the expiry date of the certificates.
Connect your mac to your router via cable, not WiFi
Boot to your Recovery HD, click on Utilities in the menubar select Terminal.
Make sure WiFi is switched off, it can reset the date back to today.
Enter a new date, for example or just copy and paste
sudo date -u 011421002017
press Return
enter your password
press Return
If Terminal returns an error saying sudo : command not found, then try again without sudo.
just enter
date -u 011421002017
press Return
You won't be prompted for a Password if you did not need to use sudo
Once the date has changed you can quit Terminal.
Now try downloading the OS.
Click on Install OS X, press Continue.
If this works then when the OS is installed and booted up you can Open System Preferences> Date & Time
and reset the time back to today.
But the big thing to take away from this experience is never erase your Mac without having your own means
to reinstall an OS on it, do not rely on Apples Servers.
Always download the OS you want to reinstall and create a bootable USB flash drive installer, then keep it in a safe
place for any future eventualities.