I recently encountered a very similar issue (Pacman database files replaced with html files)
Although for me, /var/lib/pacman/sync
existed and had its files, but they were for some reason replaced with html files for a website I have never visited, or even known of.
I have tried removing them and attempting pacman -Syyu
and yay
again, but with the same result.
If anyone could assist me with this that would be great.