iMac with a dead internal drive being used as a second monitor - booting and power efficiency
Solution 1:
What is the best way to ensure that the 2012 iMac is running at lowest power usage and optimal efficiency while in Target Display Mode?
Buy a monitor.
Yes, that's a little tounge-in-cheek, but to run Target Display Mode, you need boot macOS. When you boot macOS, you're using the CPU and GPU and everything in between (you can use the volume up/down and screen brightness keys on the keyboard so you know Bluetooth is up and running).
When it turns on, it automatically tries to boot off the dead internal hard drive, which makes the computer crash.
You need to set the startup volume in System Preferences >> Startup Disk
Once it is booted, is there a way to get it to automatically enter target display mode when it is booted?
No. This is not what Target Display Mode was intended for. It was intended to be a temporary display option. If you need something to be a monitor every time you turn it on, buy an actual monitor.
Fix your iMac
It's not economical nor efficient to to use an entire computer as just a screen. An iMac, being an AiO, doesn't change the fact it's very little different than a Mac mini with an external monitor or even a desktop PC. It wouldn't make sense to fire up an entire desktop setup just to use Target Mode (besides the fact that it already has an external monitor you can disconnect).
You have a failed hard drive in an iMac, which is not an uncommon problem. Replacing it is very easy and much more economical because you would be getting the full use out of your iMac once again.
Solution 2:
Personally, I'm using two 27" 2013 iMacs running through an Iomega TB2 KVM to serve as my desktop monitors for my 2016 MBP and my Mac Mini Server. Why? Because they're a crapton cheaper than Cinema displays (I paid 300 bucks a pop for them - eBay - then maxed their memory for another 50 bucks - otherworld on one of their myriad Garage Sale days), and, on the off chance I need to do something "sandboxed" (or just don't wanna deal with the hassle of plugging in the MacBook, my damn MONITORS are more powerful than many of the Dell PC boxes floating around nowadays.
The GOOD News
The processors and drives go pretty much dormant when in TDM mode, so your power consumption isn't notably higher than if you were running the same Cinema Displays. The key phrase there, however, is "pretty much". I swept through and disabled as many of the background processes as possible, running some logging tools to ascertain what needed to still get killed off. It took about 2 weeks to neuter the things down to "baseline".
The BAD News
@Allen is right. There's ISN'T a good way to knock them into TDM without a functional OS. It's NOT a hardware switch. It's software. You not only need the stupid thing fully-booted, you need it logged in. I went so far as making a custom 4-key macro-keypad for each that enters a set of BS Guest-Rights Creds (key 1), knocks it into/pulls it out of Target Display mode (key 2), Logs Out (so I can log in as a "real" user if inclined; key 3) and Hibernates the box (key 4).
That all said, let me tell you as someone who spent a LOT of time screwing around with this (up to and including scripting solutions, accessibility solutions, and finally hardware solutions that are acting functionally as glorified keyboards): if there's a way to "trick" one of the damn things into believing it's "just" a monitor, I haven't figured out how (I'm a 25-year software engineer and a former Apple employee - on iOS, but still - and I STILL wound up teaching myself Arduino and building a solution which itself is a workaround at best).
Boil it down, I'm not doing this for economics, or to run "green". I'm not terribly worried about my power consumption (at least, not in this case or at this scale). They still sleep just like any other monitor, and while they're absolutely using more juice than an equivalent dedicated screen, I'm not on the computer 24/7 (closer to 12/6, 6/1). And frankly? They're badass displays. But if you're truly worried about your carbon footprint, reuse is better than recycling. and the 2012's were WAY easier to open up than the 13's. For a hundred bucks or less you'd be back in business.
I'd encourage you to check out https://eshop.macsales.com/shop/garage_sale (I'm not in any way affiliated with them, outside of making enough purchases there to put their kids through college). Lest I checked they had a new drive and a new CPU you could pick up there, compatible with a 12,2 for less than 60 bucks, total.