You need your own compiled version of the engine to be able to encrypt scripts, so Godot version available for download from Godot webpage will not work.
You need to generate the key first. You may do that for example on this page
https://www.grc.com/passwords.htm that generates passwords. This password is called encryption 'key' in Godot.
New and random key is generated simply when you enter the page, so it's already waiting there or you.
That webpage generates 3 password strings for you. You should use the first '64 random hexadecimal characters (0-9 and A-F)'. It will look very similar to (but don't use this one, generate your own):
So, lets pretend the above is your new key. Now you have to compile godot with the knowledge of the key. You do that by exporting the key with command:
Then you normally compile the engine and templates.
In Godot you have to choose 'Encrypted' as a Script Export Mode and put the key into Project Export Settings > Script Encryption Key (256-bits as hex).
From now on your scripts will be encrypted.
Of course, like with all keys, it good not too loose them, so keep your key save. ;)