Rename used Magic Keyboard
I bought a used Magic Keyboard to replace the one that came with my 2019 iMac. (Don't ask why, long story...)
The steps in this thread didn't work for me till I combined multiple answers into a single workflow:
FIRST-
go to System Preferences>Accessibility and enable an on-screen Accessibility Keyboard;
THEN:
1 Connect Device
2 Go to settings, right click on device, dont click the menu, leave it open
3 Turn off Device
4 Select "rename" in the still open right click menue
5 rename the device and close the pop up
(meaning: type the name on the Accessibility Keyboard using the Mouse)
6 Turn device back on and wait for it to connect by Bluetooth
iMac Line (2012 and Later)