Can’t pair Magic Keyboard due to numerical keys not working
You should able to connect the keyboard to your Mac with a lightning cable. When you unplug it again, it should be paired. Note that it won’t be listed as (Bluetooth) paired whilst connected with a cable, but it should still be usable in that state.
Once paired, you can rename it in the Bluetooth settings.