1. Relation between the actions
The scalar action you wrote is the one for a minimally coupled field. One could use the more general action (I'm working with the $-+++$ convention and the $+++$ MTW convention for the curvature signs)
$$S = - \frac{1}{2} \int (\partial_\mu \phi \partial^\mu \phi + m^2 \phi^2 + \xi R \phi^2) \sqrt{-g} \mathrm{d}^4 x, \tag{1}$$
where $R$ is the Ricci scalar and $\xi$ is a coupling constant. This action leads to the equations of motion
$$\nabla_\mu\nabla^\mu \phi - m^2 \phi - \xi R \phi = 0.$$
This generalization is interesting, for example, when you want to consider a conformally invariant field, which is obtained by setting $m=0$ and $\xi = \frac{1}{6}$ (in $d=4$, in more generality you'd have $\xi = \frac{d-2}{4(d-1)}$).
It is worth mentioning that, in QFTCS, the metric and curvature that go into the action of Eq. (1) are assumed to minimize the Einstein–Hilbert action (or the EH action plus some matter terms) independently. That is, the metric is often taken to be a solution of the Einstein equations and one quantizes a scalar field over that classical, fixed background. Considering the backreaction of the scalar field stress-energy on the background metric is a more difficult problem and, when it is considered, one starts talking for example of Semiclassical Gravity.
2. Relation between classical and quantum Yang–Mills
In principle they don't need to relate. You'll quantize a field upon a classical gravitational background which was obtained by using a classical electromagnetic field. If you want to quantize the electromagnetic field on a Reissner–Nordström spacetime, for example, I'd guess you'd probably split the electromagnetic field in a background, classical field $\bar{A}_\mu$ and quantum fluctuations $\hat{A}_\mu$. The total field would be $A_\mu = \bar{A}_\mu + \hat{A}_\mu$, where $\bar{A}_\mu$ is the classical electromagnetic field of the RN solution and $\hat{A}_\mu$ are the quantized fluctuations.
If the classical field and the quantized field are completely different fields (for example, you're quantizing a non-abelian Yang–Mills field on Reissner–Nordström), then they have no relation to each other in principle.
There is a catch which can make things harder. For example, if you're quantizing a charged scalar field on Reissner–Nordström. That is, this time the classical field describing the metric also interacts with the quantum field. Here are the approaches I see as possible:
- Treat the electromagnetic field as classic: in this case, the electromagnetic field will change the Klein–Gordon equation, but I don't see any immediate reason to why the constructions in Wald's book, for example, would fail. Actually, I think it would amount to adding a potential to the Klein–Gordon equation, which was already treated in his 1975 paper On Particle Creation by Black Holes. However, I don't recall if that paper also considers potentials that are not compactly supported on spacetime.
- Split the electromagnetic field in classical background and quantum fluctuations: in this case, the quantum fields are quantized in the manner I described in the previous item, but you'll also have to consider the coupling in their interactions. I'm not very used to dealing with interacting fields, but I believe that can be done, e.g., with a path-integral approach. The background metric is dealt with as usual and the background electromagnetic field becomes essentially an external potential (as in the previous item).