You can do this with chpasswd. This command reads username/password pairs from stdin and updates the password of the user.
If you supply the -e option, then the password is considered to be in encrypted form. Hence, a command like this:
echo "user:*" | chpasswd -e
will change the password field for the user: user in /etc/shadow to *.
This command will also change the "date of last password change" field in /etc/shadow.