Yes, this is possible.
You can grant your Compute Engine virtual machine instance permission to access a Cloud Spanner database.
Your instance can access the Cloud Spanner API from Compute Engine by using a service account to act on your behalf.
The service account provides application default credentials for your applications so that you do not need to configure each Compute Engine instance to use your personal user credentials.
For an in-depth understanding of how you could do this, refer https://cloud.google.com/spanner/docs/configure-virtual-machine-instance
Hope this helps!
.