Password protect disk images on Mac from deleting
To keep the .dmg file from being deleted without explicit permission, you need to set the ACL permissions for the file to not be deleted. In Terminal use, e.g.:

sudo chmod +a "everyone deny delete" foobar.dmg


Once set, if you try to rename, delete, or move the .dmg file, e.g. in Finder, you'll have to enter Administrator credentials, or in Terminal use sudo, which requires the same level of credentials too, to do the same.



In Terminal, have a look at the manual page for chmod, e.g., type man chmod and press Enter, or just type chmod and right-click on it selecting, Open man Page.


In general, I'd read then entire man page however, the section titled ACL MANIPULATION OPTIONS is the relevant one to focus on.


To see what ACL permissions are set on a file/folder,  use, e.g.:

$ ls -le foobar.dmg
-rw-r--r--@ 1 me  staff  100020736 Dec  7 09:21 foobar.dmg
0: group:everyone deny delete
$