In the EXAMPLES section of the document, hdiutilit is recommended to use printffor this, and not echo -n.
Creating an encrypted single-partition image without user interaction:
printf pp|hdiutil create -encryption -stdinpass -size 9m sp.dmg
10.9 -, , 10.8. , , STDIN, 10.9.