Had a need, found a solution, reporting the procedure here.
First, you need to understand what is the disk name of the device you want to format.
For example, if you have a MacBook Pro and a SD card, this is done using disk utility, selecting the card reader where you inserted the SD card and clicking on Info button to get information about the storage.
Click to enlarge the picture below.
Even with an italian screenshot, you can grab that in my example the device name is disk4.
Open Terminal and type the command reported below to proceed with the format:
diskutil partitionDisk /dev/disk4 MBRFormat “MS-DOS FAT32” “2G” 2Gb
This will create on /dev/disk4 a FAT 32 (MS-DOS FAT16 will do a 16bit one) partition labeled 2G of 2 Gb in size.