Can I attach a .dmg without mounting the drive that it is sitting in?
If you mount a drive one of the things which happens is that the file system type gets identified so macOS afterwards knows how to access the content of the drive (and find the DMG for instance). So operating systems can't access files on a drive without mounting it first.

Your actual problem seems to come from the fact that TestDisk is a tool to recover data from physical drives. So it could be used to work with the original disk your DMG represents, but it won't be able to recover data from a DMG.