Encrypt an HFS+ Partition From the Terminal

Use the following diskutil syntax to encrypt a partition on MacOS from the Terminal:

diskutil cs convert /Volumes/MyDrive -passphrase

You do not enter a passphrase on the command line, but rather you will be prompted for one.