Download macOS installer
It turns out you can still download macOS versions from the App Store, using direct links, even though it's not visible in the Purchased section any more (probably requires previous purchase, but not sure). Here are the links to a few recent versions:
It will start downloading in the Settings app; this is expected.
Install as a Parallels VM
Although you obviously won't be able to run the installer from a newer macOS, you can create a virtual machine easily as Parallels will offer to install the OS for you. Just choose "Install Windows or another OS from a DVD or image file" and then select the installation image. Parallels will then prompt you to create a bootable disk image file (*.hdd format).
Install on other VMs or hardware
Once you have the bootable disk image file from Parallels (yeah, unfortunately you need Parallels for this; but you can use a free trial if you do not have a license) you can convert this into a DMG file like so:
- Right click the bootable disk image file (*.hdd) file that Parallels created for you (see above)
- Choose "Show package contents..."
- Copy the "*.hdd.hds" file to a different location
- Rename it to *.dmg