I assume it's an EXE file even if it is called .com; It is possible but complicated to do completely in memory (if dos.com has threads or uses DLLs). A relatively simple way, if it is acceptable, is to put a copy of dos.com into your executable (as a RES file, or with staticRead, or something like that), and then your Nim program can write a copy of "dos.com" and run that copy.
This will require space you can write to, and might trigger some anti viruses - but that's the kind of thing that e.g. PyInstaller does to pack a Python project with all dlls and graphics files into one executable.
