In macOS the root user is DISABLED by default. Also note, macOS is not Linux! You should really use sudo as @Philippe suggested.
In a Terminal window:
sudo su -
Result
$ sudo su -
Password:
macmini8:~ root# passwd
Changing password for root.
New password:
Retype new password: