iMac issues: indicates hard disk needs replacing and can't get through AHT, should I do any other tests?
It doesn’t necessarily need a hard drive. Have you erased it and tried installing an OS?
You’ll need an external bootable OS for this on 2011 era hardware.
Only if you can’t get that working would you need a repair. A failing disk usually doesn’t cause shutdowns without logging a prodigious amount of IO errors and any technician should be able to read the SMART statistics to conclude the drive is malfunctioning or error free. If you need help locating a trained shop, try https://locate.apple.com
Best of luck with getting this repaired! (But only if it needs it)