Get drive name

    diskutil list

then try

    diskutil unmountDisk force /dev/DRIVENAME

Then format

    diskutil eraseDisk JHFS+ Emptied /dev/DRIVENAME

or

    diskutil eraseDisk FAT32 Emptied /dev/DRIVENAME