The solution was to download https://packages.msys2.org/packages/mingw-w64-x86_64-libyaml and install it manually by opening C:\Ruby33-x64\msys64\msys2
and running:
pacman -U /c/Users/burkipe/Downloads/mingw-w64-x86_64-libyaml-0.2.5-2-any.pkg.tar.zst
I then needed to specify the libyaml directory as so, in Git bash:
gem install psych -v 5.1.2 -- --with-libyaml-dir=/C/Ruby33-x64/msys64/mingw64/