The resulting file may have a .img.dmg extension β you can use it as-is.
The command syntax varies slightly depending on the macOS version. Here are the most common versions: create mac os x bootable usb installer from dmg