+1 to what Keith Barkley posted . target Display mode is dead for all recent Macs..,plus you need a working Mac to even try , and your iMac isn’t working… try doing Recovery mode on your iMac first, reboot holding down Apple+R keys together on its keyboard ; use a usb wired keyboard and mouse on your iMac… you should see a language screen, pick one and continue… to get to Mac OS Tools, move your arrow to the top centre of your screen… run Disk Utility, if your hard drive /ssd is OK, reinstall macOS… if it needs minor fixing, let Dudk Utility do it, then try reinstalling Mac OS.. if Disk Utility can’t fix it, then you’re gonna have to buy an app/software to do that; probably… if it CAN fix it, that is, if not, your HD/ssd is probably hosed - needs replacing… the only way to do what you suggest/hope is a 3rd party device called Duet Display( $150) … a 27” hdmi monitor ( even used+’in good condition) could be had for $100-ish
john B