I had this problem on Mojave and it seems nothing solves the combination of APFS and automatic mounting of volumes.
However, if you have an encrypted volume, it is possible to disable the prompting for the volume password which keeps the volume from being mounted.
The part that does the prompting for the password is the file bundle:
/System/Library/CoreServices/SecurityAgentPlugins/DiskUnlock.bundle
If you disable SIP (System Integrity Protection), you can rename the file to something else, e.g. DiskUnlock.bundlexxx and you will no longer be prompted for a password. (SIP can be re-enabled after the change.)
DOWNSIDES include that no encrypted volume will be mountable via the GUI (including using the Disk Utility).
The only way to unlock an encrypted volume is through diskutil or by storing the passphrase in the system Keychain.
You can mount encrypted volumes with something like:
$ diskutil apfs unlockVolume [Volume GUID here] -passphrase [Passphrase here]
The volume ID is obtained with the output from:
diskutil apfs list
....
+-- Container disk3 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX [ignore the GUID here]
====================================================
APFS Container Reference: disk3
Size (Capacity Ceiling): 5000771321856 B (5.0 TB)
Capacity In Use By Volumes: 577949696 B (577.9 MB) (0.0% used)
Capacity Not Allocated: 5000193372160 B (5.0 TB) (100.0% free)
|
+-< Physical Store disk2s2 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX [ignore the GUID here]
| -----------------------------------------------------------
| APFS Physical Store Disk: disk2s2
| Size: 5000771321856 B (5.0 TB)
|
+-> Volume disk3s1 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX [ <---HERE IS THE GUID YOU WANT]
---------------------------------------------------
APFS Volume Disk (Role): disk3s1 (No specific role)
The passphrase is whatever you picked for the password for the encrypted volume.
Also, if you saved a password for the volume in the system Keychain, you'll need to remove it using the Keychain Access utility.
There is a tool that avoids having to type these commands manually:
Semulov on Github