Starting in safe mode without a keyboard If your Mac doesn’t have a keyboard available to start in safe mode but you have remote access to it, you can configure the Mac to startup in safe mode using the command line. Access the command line by either opening Terminal remotely, or by logging into the computer using SSH. Use the following Terminal command:
sudo nvram boot-args=”-x”
If you want to start in verbose mode as well, use this instead:
sudo nvram boot-args=”-x -v”
After using safe mode, use this Terminal command to return to a normal startup:
sudo nvram boot-args=""
Source: Try safe mode if your Mac doesn’t finish starting up – Apple Support