How to obtain a secure copy of macOS? I need to install macOS on a VM. I don't want to download a macOS from torrent or hackintosh websites. Is there a way I can verify a macOS image's signature so I know it came from apple?
The only reliable (and legal) source of macOS is the Mac App Store. 

There are python scripts to download from Apple as well. Apple code signs the installers, so you are taking on risk to re-implement or bypass those checks.