Yes, I solved the issue.
I created a secret in the MongoDB values and referenced it. Into the secret went the credentials itself (the JSON).
Then, you can read it from the functions like this (assuming you named the link ‘firebase_credentials’):
const firebase_credentials = context.values.get("firebase_credentials");
const doc = JSON.parse(firebase_credentials);
admin.initializeApp({
credential: admin.credential.cert(doc),
});