Running iMac 2009 on external screen due to Broken LCD
Yes it is possible to diagnose and install macOS on an iMac with a broken LCD and missing hard drive.

The iMac all-in-ones from that vintage has a mini Display Port for a second display.  It supports Leopard through El Capitan.  Here’s what you’ll need at a minimum:


A mini display port to VGA, DVI, or HDMI adapter, depending on the monitor you’re hooking up to.
A bootable USB - either an installer or a USB with a full installation on it.  You can create an installer by following one of the many guides found online.  If you want to use the full install, you’ll need to install macOS to a USB flash (64GB is sufficient) or a USB hard drive.


As for a keyboard, I’m assuming it comes with one, but if it doesn’t, you don’t need an Apple one; a cheap USB keyboard will work fine. Just remember, the “Windows” and “Alt” keys are the Command and Option keys, respectively.