There is nothing to do when $\det\big(B\big)=0$ so we consider the case when $B\in GL_n\big(\mathbb R\big)$.
$A':= \left[\begin{matrix}0 & -1\\1 & 0\end{matrix}\right]$
$A \in GL_n(\mathbb R)$ has eigenvalues in (the extension field $\mathbb C$) $\lambda \in \big\{i,-i\big\}$ which must come in conjugate pairs hence $n=2\cdot m$ . $A$ is similar to its Rational Canonical Form given by, for some $S \in GL_n(\mathbb R)$
$S^{-1}AS = \left[\begin{matrix}A' & \mathbf 0&\cdots&\mathbf 0\\\mathbf 0 & A'&\cdots &\mathbf 0\\ \vdots&\vdots &\ddots &\vdots \\ \mathbf 0&\mathbf 0 &\mathbf 0 &A'\end{matrix}\right]$
which is permutation similar to the symplectic matrix $J$
$J=\left[\begin{matrix}\mathbf 0 & I_m\\-I_m & \mathbf 0\end{matrix}\right]= (SP)^{-1}A(SP)=W^{-1}AW $
$Z:= W^{-1}BW$
and conjugation preserves commutativity so
$ZJ= JZ\implies Z^TJ= JZ^T$
Justification: transposing, then negating each side (or applying Fuglede's Theorem)
$\implies J\big(Z^TZ\big) = \big(JZ^T\big)Z = \big(Z^TJ\big)Z= Z^T\big(JZ\big)= Z^T\big(ZJ\big)=\big(Z^TZ\big) J$
which implies, when working over $\mathbb C$, that $J$ and $\big(Z^TZ\big)$ are simultaneously diagonalizabile which implies $J$ also commutes with the square root $(Z^TZ)^\frac{1}{2}$. (Alternatively, staying in $\mathbb R$, Spectral Theorem for real symmetric matrices, and e.g. interpolating with a Vandermonde matrix, tells us $(Z^TZ)^\frac{1}{2}$ can be written as a polynomial in $(Z^TZ)$ hence it commutes with $J$.)
applying Polar Decomposition, we have
$Z=Q\big(Z^TZ\big)^\frac{1}{2}$
$JQ\big(Z^TZ\big)^\frac{1}{2}=JZ=ZJ=Q\big(Z^TZ\big)^\frac{1}{2}J=QJ\big(Z^TZ\big)^\frac{1}{2}\implies JQ=QJ$
finish 1: via symplectic group:
via left multiplication by $Q^T$
$\implies Q^T J Q =J$
Thus $Q\in SP_{2n}\big(\mathbb R\big)$
i.e. $Q$ is in the symplectic group (which is path connected) so $\det\big(Q\big) =1$ and
$\det\Big(B\Big)=\det\Big(W^{-1}BW\Big) = \det\Big(Z\Big)= \det\Big(Q\big(Z^TZ\big)^\frac{1}{2}\Big) = 1 \cdot \det\Big(\big(Z^TZ\big)^\frac{1}{2}\Big)\geq 0$
finish 2: J-invariance:
Suppose for contradiction that $\det\big(Q\big) = -1$. This implies $Q$ has an odd amount of eigenvalues equal to $-1$ so $\dim \ker \big(Q+I\big) = r$ which is odd.
$J\big(Q+I\big)= \big(Q+I\big)J$ so $\ker \big(Q+I\big)$ is a $J-$ invariant subspace of odd dimension. Let $\mathbf B$ and $\mathbf B'$ be two different bases for $\ker \big(Q+I\big)$. $\mathbf B$ is created the typical way by collecting $r$ linearly independent vectors from $\ker \big(Q+I\big)$ -- these coordinate vectors necessarily have all real components. Now working over $\mathbb C$, we create $\mathbf B'$, also a basis for $\ker \big(Q+I\big)$, this time using eigenvectors from $J$ (ref e.g. here For a real symmetric matrix $A$, are the subspaces given by the span of eigenvectors the only $A$-invariant subspaces? ).
So $J\mathbf B = \mathbf B M$ and $J\mathbf B' = \mathbf B' M'$, for $M,M' \in GL_{r}\big(\mathbb C\big)$. Then $M$ and $M'$ are similar so $\text{trace}\big(M\big)=\text{trace}\big(M'\big)$.
$M$ is real (because $J$ and $\mathbf B$ are) so $\text{trace}\big(M\big)\in \mathbb R$. But $M'$ is a diagonal matrix with all entries equal $\pm i$ so $\text{trace}\big(M'\big)\in i\cdot\mathbb R \implies \text{trace}\big(M\big)=\text{trace}\big(M'\big)\in \mathbb R \cap i\cdot\mathbb R =\big\{0\big\}$, which gives the linear system
$\left[\begin{matrix}i & -i\\ 1 &1 \end{matrix}\right]\left[\begin{matrix}x_1\\ x_2 \end{matrix}\right]=\left[\begin{matrix}0\\ r \end{matrix}\right]\implies \left[\begin{matrix}x_1\\ x_2 \end{matrix}\right]=\left[\begin{matrix}\frac{r}{2}\\ \frac{r}{2} \end{matrix}\right]$
which is a contradiction since the the algebraic multiplicities ($x_i$) of eigenvalues must be natural numbers. [Alternatively note $M$ has real components but is similar to $M'$ which has all non-real eigenvalues which cannot come in conjugate pairs since $r$ is oddd.]
Thus $\det\big(Q\big)=1$ and once again
$\det\Big(B\Big)=\det\Big(W^{-1}BW\Big) = \det\Big(Z\Big)= \det\Big(Q\big(Z^TZ\big)^\frac{1}{2}\Big) = 1 \cdot \det\Big(\big(Z^TZ\big)^\frac{1}{2}\Big)\geq 0$