If you configured an instance to allow SSH as the root user and configure an SSH key for the root user on that instance, you can connect as root using the gcloud compute ssh command with root@ specified before the instance name:
gcloud compute ssh --project [PROJECT_ID] --zone [ZONE] root@[INSTANCE_NAME]
- [PROJECT_ID] is the ID of the project that contains the instance.
- [ZONE] is the name of the zone in which the instance is located.
- [INSTANCE_NAME] is the name of the instance.