Use losetup and dd to make filesystems images ready to be deployed

As killermist mentioned, the error was that I had forgotten to create partitions before creating a filesystem. The instructions in the question are correct and create perfectly valid disk images, all one has to do is to create partitions, just after mounting the loop device, and just before creating a filesystem on it.
So the correct sequence is
losetup....
parted --script /dev/loop0 mktable msdos mkpart primary 2048s 100%
sudo mkfs...