Hard drives as well as solid state drives don't loose their content just by unplugging them. So you can take the drive out and then put it back and the system would be like it was.
As to upgrading think of it this way you have two shoes but only one sock so only one foot can have the sock! This is the same type of conundrum you face here! So how to over come it??
First make sure you have a newer version of MacOS installed, then create a USB OS installer following this guide: How to create a bootable macOS Sierra installer drive That way when you swap the drive out you can install a fresh copy of OS onto your drive.
The next step is to get this: Startech 2.5" SATA to USB adapter so you can plug in your old drive in - The spare sock you had in the drawer ;-} Now at the end of the OS install process plug in your old drive so you can then migrate your user accounts, apps & data over.
Thats It! Done
But! There is a few things more I would do here!
This series has a known issue with a bad HD SATA cable so I would take the time to replace when I put in the new drive. Follow this IFIXIT guide: MacBook Pro 13" Unibody Mid 2012 Hard Drive Cable Replacement and use this version of the part MacBook Pro 13" Unibody (Mid 2012) Hard Drive Cable. In addition I would place some electrical tape onto the upper case where the cable rests against it. As the ruff surface of the case is known to cause abrasion.
Lastly here is the IFIXIT guide to replace the RAM: MacBook Pro 13" Unibody Mid 2012 RAM Replacement