Manjaro: Keys could not be locally signed

I just encountered an issue on my Manjaro installation that prevented me from installing any software from Pacman due to key signing errors (eg. ERROR: 962DDE58 could not be locally signed.). This results from an error with the GnuPG local master key, which becomes unable to sign other keys. Fortunately, this key can be regenerated!

sudo rm -rf /etc/pacman.d/gnupg
sudo pacman-key --init
sudo pacman-key --populate archlinux manjaro

I also had this issue on a live USB stick, and for some reason here I could not delete /etc/pacman.d/gnupg, but I could delete it's contents.

# Initialise and populate a new directory
sudo pacman-key --gpgdir .pacman-gnupg --init
sudo pacman-key --gpgdir .pacman-gnupg --populate archlinux manjaro

# Copy the contents to the system directory
sudo rm -rf /etc/pacman.d/gnupg/*
sudo cp -r .pacman-gnupg/* /etc/pacman.d/gnupg/

Hopefully, it should now work again!