Editing the main sshd_config gets messy at the next package update. A small drop-in file is easier to keep.
echo 'PasswordAuthentication no' | sudo tee /etc/ssh/sshd_config.d/10-hardening.conf
sudo sshd -t && sudo systemctl reload ssh
sudo sshd -T | grep passwordauthentication
Current Debian and Ubuntu releases start sshd_config with Include /etc/ssh/sshd_config.d/*.conf. In sshd the first value for a keyword wins, and files are read in alphabetical order, so a name starting with 10- beats cloud images that ship 50-cloud-init.conf with PasswordAuthentication yes.
Always confirm with sshd -T, and make sure your public key works before you reload. Keeping the change in one small file also makes it easy to remove again.
Further reading: sshd_config manual page