Edit Read Only DMG using a shadow file

Attach read-only dmg file using hdiutil

hdiutil attach -owners on /path/to/your.dmg -shadow

Modify your DMG. Use the command line to add, edit or delete contents – doing it in the GUI can have weird side effects or permission issues. Additionally, you may need to sudo the commands

Detach mounted drive by below command or Eject it from Finder

# fill disk number at

hdiutil detach /dev/disk5

Converting/Writing a shadowed dmg into read-only DMG

hdiutil convert -format UDZO -o /path/to/new.dmg /path/to/your.dmg -shadow