This will create a 7-zip archive of the current directory protected by a password
7z a filename.7z -pPASSWORD
where a stands “Add files to archive” and PASSWORD is the password. To archive a different directory use:
7z a filename.7z -pPASSWORD /path/dir
To extract this file
7z x filename.7z -pPASSWORD
where x stands for extract. You can use 7za where 7z binary is not available.