pacman / yay unfortunately do not work directly on the Steam deck because the required certificates are not present or trusted.
Make pacman work
sudo steamos-readonly disable
sudo pacman-key --init
sudo pacman-key --populate archlinux
Som installer are needing locales working. I edited /etc/locale.gen to enable UTF 8 and ISO, only uncomment the lines and than start this comman:
sudo locale-gen
You should definitely make sure that the software installed in this way is not installed on the Home partition, as is usually the case with flatpak. With a new installation, these are overwritten.
In addition, you can really break something and possibly prevent the next Steam update or cause an error.