Use vi -x filename to edit (or create) a file. vi prompts you to set a password, after which it encrypts the content of the file.
You will need to use this password every time you vi the file.
$ vi -x filename
Enter encryption key: password
this is a test
$ file filename
filename: Vim encrypted file data