I recently found myself remotely installing/upgrading MySQL on a remote MacOS machine without GUI access. It's an old but solid PowerMac G5 running 10.5 Leopard. I couldn't remember how to do this, but a quick search provided the following solution.
The first step was mounting the disk image (dmg):
$ sudo hdiutil attach
The volume will be mounted at /Volumes/<dmg>
Next, install the pkg file:
$ sudo installer -pkg /Volumes/<dmg>/<pkg> -target /
Lastly, cleanup: