You can attempt to repair problems on the Pi by rebooting to a root shell.
Append init=/bin/sh at the end of cmdline.txt and reboot. (This will need to be done on another computer.)
After booting you will be at the prompt in a root shell.
Your root file system is mounted as readonly now, so remount it as read/write
mount -n -o remount,rw /
You can then ...
On my Raspberry Pi 3 with RaspiOS 2020-05-27 Buster (based on Debian 10.4) the problem exists if I run raspi-config into a ssh shell and without a phisical keyboard attached. If an USB keyboard is attached, the dpkg-reconfigure keyboard-configuration command (or the relative raspi-config option) does indeed work, even if invoked into an ssh session.