What I have done -
Compiled the script and tried to add it to a policy to my Mac via Jamf. It worked as expected. I tested with a user and it failed. The only difference between us that I have noted is I grabbed gcloud cli tools via homebrew; the user grabbed it via tar.
I've tried which gcloud config set core/custom_ca_certs_file ~/ca.pem
and various other methods to get this going. Have you tried anything similar and gotten it going for your environment?