In general, this cannot be done. For example, in dimension $2$ in coordinates $(x,y)$, let $$ G(x,y) = \left[\begin{matrix}x&y\\y&-x\end{matrix}\right]. $$ If $G$ could be diagonalized by a differentiable invertible matrix $A(x,y)$, i.e., if $$ A^T G A = \left[\begin{matrix}\lambda_1&0\\ 0&\lambda_2\end{matrix}\right] $$ where $\lambda_1$ and $\lambda_2$ were differentiable, then the $\lambda_i$ would have to vanish at $x=y=0$. Taking determinants yields $$ -(x^2+y^2)(\det A)^2 = \lambda_1\lambda_2\,. $$ Then, looking at the lowest order terms on each side (the terms of order $2$), you'd have $x^2+y^2$ written as a product of two factors linear in $x$ and $y$, which is impossible. For similar reasons, you cannot achieve $$ G = A^T\left[\begin{matrix}\lambda_1&0\\ 0&\lambda_2\end{matrix}\right]A $$ for a differentiable $A$ and $\lambda_i$. The above argument shows that $A$ could not be invertible, so we would have to have $\det A$ vanishing at $x=y=0$. Then $-(x^2+y^2) = (\det A)^2\lambda_1\lambda_2$ would imply that $\det A$ vanishes at most to order 1 at $x=y=0$ and that $\lambda_1$ and $\lambda_2$ do not vanish at $x=y=0$, which again gives a contradiction, since $x^2+y^2$ is not the square of a linear term. In fact, one cannot have $$ G = A^T\left[\begin{matrix}\lambda_1&0\\ 0&\lambda_2\end{matrix}\right]A $$ with $A$ and $\lambda_i$ being merely *continuous* on some disk $ x^2+y^2\le \epsilon^2$ for some $\epsilon>0$. Here is why: The relation $-(x^2+y^2) = (\det A)^2\lambda_1\lambda_2$, shows that $\det A$, $\lambda_1$ and $\lambda_2$ must be nonzero away from $(x,y)=(0,0)$, so each $\lambda_i$ cannot change sign and we must have $\lambda_1\lambda_2<0$ away from $(x,y)=(0,0)$. Without loss of generality, we can assume that $\lambda_1 = \mu_1^2$ and $\lambda_2=-\mu_2^2$, where the $\mu_i$ are continuous, so by modifying $A$ in the obvious way, we can reduce to the case that $\lambda_1 = -\lambda_2 = 1$ and, moreover, that $\det A = \sqrt{x^2+y^2}>0$. The mapping $f:S^1\to\mathrm{SL}(2,\mathbb{R})$ defined by $$ f(\theta) = \frac1\epsilon A(\epsilon\cos\theta,\epsilon\sin\theta) $$ then satisfies $$ f(\theta)^T\left[\begin{matrix}1&0\\ 0&-1\end{matrix}\right]f(\theta) = \left[\begin{matrix}\cos\theta&\sin\theta\\ \sin\theta&-\cos\theta\end{matrix}\right]. $$ Now, consider the map $s:\mathrm{SL}(2,\mathbb{R})\to H$ (where $H$, a hyperboloid of one sheet, is the quadric surface in the symmetric $2$-by-$2$ matrices defined by setting the determinant equal to $-1$) defined by $$ s(A) = A^T\left[\begin{matrix}1&0\\ 0&-1\end{matrix}\right]A. $$ Both $\mathrm{SL}(2,\mathbb{R})$ and $H$ are homotopic to the circle and hence have $\pi_1\simeq \mathbb{Z}$. The map $s$ carries the generator of $\pi_1(\mathrm{SL}(2,\mathbb{R}))$ to twice a generator of $\pi_1(H)$. However, the above formula for $f$ shows that $s\circ f:S^1\to H$ carries a generator of $\pi_1(S^1)$ to a generator of $\pi_1(H)$, which is impossible.