Samba's sambaNTPassword attribute, which mimics the corresponding NT / Active Directory attribute, has a value that must be a hex encoded MD4 hash of the user's password with a UTF-16 encoding. Fortunately generating such a string is a Python one-liner.
password = 'fred123'
nt_password = hashlib.new('md4', password.encode('utf-16le')).digest().encode('hex').upper()
Note that Samba wants all the alpha characters in the string as upper-case.The result will always be 32 characters long.