There is a Weyl integration formula that deals with this problem. $\newcommand{\eS}{\mathscr{S}}$ $\newcommand{\bR}{\mathbb{R}}$ Denote by $G_n$ the space of symmetric $n\times n$ real matrices. It states that for any $O(n)$-invariant $h:G_n\to \bR$ we have
$$ \frac{1}{ (2\pi)^{ \frac{m(m+1)}{4} } } \int_{G_n} h(A) e^{-\frac{tr A^2}{4} } dA=\frac{1}{Z_n}\int_{\bR^n} h(\lambda_1,\dotsc, \lambda_n) e^{-\frac{1}{4}\sum_{j=1}^n \lambda_j^2 } \prod_{j<k}|lambda_j-\lambda_k| d\lambda_1\cdots d\lambda_n. $$
where
$$Z_n =2^{\frac{n}{2}}n! \prod_{j=1}^n \Gamma(\frac{j}{2}).$$
Now let
Now use this formula for
$$ h(A)= f(g(A)) e^{\frac{tr A^2}{4}}. $$