Definition: A metric $ g$ on a manifold $ M$ is a tensor field of type $ (0,2)$ such that
(1) it is symmetric, i.e. $ g(v,w)=g(w,v)$ for any $ w,v \in V_p, p\in M$, and
(2) it is non-degenerate, i.e. if $ v_1 \in V_p$ such that $g(v_1,v)=0$ for any $ v \in V_p$, then $ v=0$.
($V_p$ denotes the tangent space at $p$)
Theorem: Given a metric $ g$, there exists some orthonormal basis $v_1,...,v_n$ for $ T_p$ for each $ p \in M$, i.e. $ g(v_\mu,v_\nu)=\pm \delta_\mu^\nu$. Moreover, if $ S,S'$ are two orthonormal basis, then
$$\#\{s \in S: g(s,s)=1\}=\#\{s' \in S': g(s',s')=1\}$$
and
$$\#\{s \in S: g(s,s)=-1\}=\#\{s' \in S': g(s',s')=-1\}$$
For the first part, I am wondering there is anything like the Gram-Schmidt process which can be applied to this case, but since the metric may not be positive definite, I can't see how I can do so.
For the second part, I do not have any idea how to approach it.
Thank you for providing me suggestions.
Suppose we have a Semi-Riemannian manifold $(M^n,g)$ with metric signature $(n-k,k)$. By definition, each $p \in M$ the map $g_p : T_pM \times T_pM \to \Bbb{R}$ is a non-degenerate, symmetric, bilinear form. We can find an orthonormal basis for $T_pM$ for any $p \in M$ using induction as shown in this lemma (lemma 24 of Barrett O'neill's Semi-Riemannian Geometry, p.50).
For the second question, it's enough to do that in the level of vector space. Suppose $V$ is a $n$-dimensional real vector space endowed with a non-degenerate, symmetric bilinear form $g : V \times V \to \Bbb{R}$. Let $\{e_1,\dots,e_n\}$ is an arbitrary orthonormal basis for $V$.
Let $k \leq n$ be the number of negative values in $\{g(e_i,e_i)=\pm1 : i=1,\dots ,n\}$. The case $k=0$ is trivial. If $k>0$, then $V$ will have a subspaces which $g$ is negative definite, e.g. the span of one of the basis elements. Let $W$ be the subspace of maximal dimension on which $g$ is negative definite. If we can show that $k=\text{dim }W$ then we're done since this number $k$ is independent of basis.
By rearranging the basis $\{e_1,\dots,e_k,e_{k+1},\dots,e_n\}$, we have $g(e_i,e_i)=-1$ for $1\leq i \leq k$ and $g(e_j,e_j)=1$ for $k+1\leq j \leq n$. Since $g$ negatives definite on $X = \text{span} (e_1,\dots,e_k)$ then $k=\text{dim }X \leq \text{dim }W$. To show $k \geq \text{dim }W$, define a map $T : W \to X$ as follow; for any $w = \sum_{i=1}^n w^i e_i \in W$ $$ T(w) = \sum_{i=1}^k w^ie_i. $$ You can check directly that $T$ is injective and therefore $\text{dim }W = 0 + \text{dim Im }T \leq \text{dim }X=k$. Therefore the number $k$ is fixed by $g$, independent of basis.