You can drag the .dmg to Terminal at the appropriate point in typing the command & it will set the name & path for you.
You can essentially do the same for the output, but change the name.
In essence... Type or copy/paste...
hdiutil convert (then drag dmg here, then type the next bit) -format UDTO -o (drag it again, then backspace a bit & change the name)
Clumsy, but effective.