Let $M_n(\mathbb{C})$ be the set of $n\times n$ matrices over the complex numbers. Let $S \in M_n(\mathbb{C})$. A matrix $A\in M_n(\mathbb{C})$ is said to be $S$-skew-Hermitian if $SA^*=-AS$ where $A^*$ is the conjugate transpose of $A$. The set $\mathfrak{u}_S$ of all $S$-skew-Hermitian matrices is a Lie algebra. In this paper, we give a real dimension formula for $\mathfrak{u}_S$ using the Jordan block decomposition of the cosquare $S(S^*)^{-1}$ of $S$ when $S$ is nonsingular.