Virtual HDD might be simpler at first, so I'll use it as an example, I'll also assume Qemu, if you're using some other hypervisor/emulator then you'll need to check what disk image format it supports.
You just create a file with whatever contents you want the virtual HDD to have, assuming RAW format. So first 512 bytes of the file are the first sector contents. Just write MBR there (assuming you want to boot the Qemu using this disk image), and write whatever you like in other sectors, it's your OS, so it's up to you.
If that doesn't answer your question, then you'll have to be more specific. Note, when I earlier asked for more details, I wasn't asking about other OS's but rather about yours, the question itself is a bit too vague to answer properly.
Btw, how do you boot your OS now? Have you read the PC boot stuff:
http://wiki.osdev.org/Boot_Sequencehttp://wiki.osdev.org/System_Initialization_(x86)You should have some idea what you want to achieve here, explaining that and related details would enable us to answer better. Like do you want the disk image to have some specific file system or not, how your OS expects to be booted, what boot loader/MBR you want to use, how your OS files should be laid out in the disk image/file system, etc.. These are all details you will have to _decide_, so we can't know them..