MacOS has a pop up that tries to identify the keyboard layout. If this screen came up when I plugged something in that wasn’t a keyboard, I would assume the device was malicious.
It is probably possible to automate the keystrokes to quickly kill this screen though.