First download the install app bundle. Older versions can be hard to find but the current version of the time you read this, can be found in the App Store.
To create a drive run this command: hdiutil create -o /tmp/Mojave.cdr -size 6200m -layout SPUD -fs HFS+J
.
Next you will need to mount that drive hdiutil attach /tmp/Mojave.cdr.dmg -noverify -mountpoint /Volumes/install_build
.
Use the downloaded app bundle to create the media: sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build
.