By definition, restoring to factory settings means wiping all the applications except what would be factory installed such as iTunes, Safari, etc. I believe it should be possible to do a "factory reset" to High Sierra though through Internet Recovery. It might work to just install on top of your current setup, but it won't wipe your personal data, if that's what you were looking to do.
How to reinstall macOS - Apple Support
||Install the latest macOS that was installed on your Mac, without upgrading to a later version.*
||Upgrade to the latest macOS that is compatible with your Mac.**
Requires macOS Sierra 10.12.4 or later
|Install the macOS that came with your Mac, or the version closest to it that is still available.
I believe the mention about Sierra 10.12.4 means that the firmware update required to perform it would be installed automatically with the OS updates. But if that firmware update is installed and an earlier version is then reinstalled, it should still be able to access that.
I'm still not quite sure what would be considered the "version that came with your computer" for a mid-2012 MBP although they do say "the version closest to it that is still available". The mid-2012 MBP initially came out with Snow Leopard, and over the years it shipped with Lion, Mountain Lion, Mavericks, and Yosemite. I heard it's supposed to be Lion because Internet Recovery doesn't have Snow Leopard on its servers.