ok so since you have a late 2012 iMac simply stated yes. It is not for the faint of heart and I have posted a guide for it on my website.
It just so happens that my article is about Mountain Lion
You will just need to download Mountain Lion from the Mac App Store and store it on a drive for when you decide to get rid of your Mac.
With that being said, I'm not really sure who would want to have Mountain Lion years after it has been discontinued so it may be more worth your while and more enticing if it has a later OS on it as it saves the future user the time spent downloading and installing newer versions of OS X.