You want to format a partition in a disk-image file, rather than the entire image file.  In that case, you need to use losetup to tell linux to use the  image file as a loopback device.
NOTE: losetup requires root privileges, so must be run as root or with sudo.  The /dev/loop* devices it uses/creates also require root privs to access and use.
e.g (as root)
# losetup /dev/loop0 ./sdcard.img
# fdisk -l /dev/loop0
Disk /dev/loop0: 1 MiB, 1048576 bytes, 2048 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x54c246ab
Device       Boot Start   End Sectors   Size Id Type
/dev/loop0p1          1  1023    1023 511.5K  c W95 FAT32 (LBA)
/dev/loop0p2       1024  2047    1024   512K 83 Linux
# file -s /dev/loop0p1
/dev/loop0p1: data
# mkfs.vfat /dev/loop0p1 
mkfs.fat 3.0.28 (2015-05-16)
Loop device does not match a floppy size, using default hd params
# file -s /dev/loop0p1
/dev/loop0p1: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", sectors/cluster 4, root entries 512, sectors 1023 (volumes <=32 MB) , Media descriptor 0xf8, sectors/FAT 1, sectors/track 32, heads 64, serial number 0xfa9e3726, unlabeled, FAT (12 bit)
and, finally, detach the image from the loopback device:
# losetup -d /dev/loop0
See man losetup for more details.