I will show this for the $2 \times 2$ case by explicitly doing the matrix multiplication. You can either generalise this to the $n \times n$ case yourself, or wait for someone with a more elegant answer.
Matrices $A$ and $B$ are congruent, i.e. there exists an invertible matrix $P$ such that: $ P^{T}AP = B.$ Write out the elements of the matrices and perform the matrix multiplication, i.e. $ \left( \begin{array}{cc} p_{11} & p_{21} \\ p_{12} & p_{22} \end{array}\right)\left( \begin{array}{cc} a_{11} & 0 \\ 0 & a_{22} \end{array}\right)\left( \begin{array}{cc} p_{11} & p_{12} \\ p_{21} & p_{22} \end{array}\right) = \left( \begin{array}{cc} b_{11} & 0 \\ 0 & b_{22} \end{array}\right),$ $\left( \begin{array}{cc} p_{11}^{2}a_{11} + p_{21}^{2}a_{22} & p_{11}p_{12}a_{11} + p_{21}p_{22}a_{22} \\ p_{11}p_{12}a_{11} + p_{21}p_{22}a_{22} & p_{12}^{2}a_{11} + p_{22}^{2}a_{22}\end{array}\right) = \left( \begin{array}{cc} b_{11} & 0 \\ 0 & b_{22} \end{array}\right).$ To satisfy this equation let $p_{12} = p_{21}= 0$. In this case $b_{jj} = a_{jj}p_{jj}^{2}$, i.e. the signs of the $j$-th entries in $A$ and $B$ are the same.