Here is a few sample examples of how to format a drive in Terminal.
Click Applications > Utilities > Terminal.
Always run Diskutil list. This will show you the list of the drives on that computer which will help you identify which drive name is needed to for the DiskNoteID at the end of the terminal command.

Formatting a Disk to Mac OS Extended Journaled (JHFS+) from Terminal in Mac OS X
diskutil eraseDisk JHFS+ DiskName /dev/DiskNodeID
Formatting a Disk to Mac OS Extended (HFS+) from Terminal in Mac OS X
diskutil eraseDisk HFS+ DiskName /dev/DiskNodeID
Formatting a Disk to MS-DOS fat32 from the Command Line in Mac OS X
diskutil eraseDisk FAT32 DiskNameGoesHere /dev/DiskNodeIDHere
Formatting a Disk to ExFAT from the Command Line in Mac OS X
diskutil eraseDisk ExFAT DiskName /dev/DiskNodeID

diskutil eraseDisk
Usage: diskutil eraseDisk format name [APM[Format]|MBR[Format]|GPT[Format]]
MountPoint|DiskIdentifier|DeviceNode
Completely erase an existing whole disk. All volumes on this disk will be
destroyed. Ownership of the affected disk is required.
Format is the specific file system name you want to erase it as (HFS+, etc.).
Name is the (new) volume name (subject to file system naming restrictions),
or can be specified as %noformat% to skip initialization (newfs).
You cannot erase the boot disk.
Example: diskutil eraseDisk JHFS+ UntitledUFS disk3
Frequently used Sample:
diskutil eraseDisk JHFS+ Macintosh HD /dev/disk0
diskutil eraseDisk ExFAT Data /dev/disk0
