Given a positive semidefinite, real $2n \times 2n$ matrix $A$, is there a formula or an algorithm that finds the closest (in some sense, preferably Frobenius distance) positive semidefinite, real $2n \times 2n$ matrix $B$ such that $B + Q$ is also positive semidefinite?
If it is relevant,
$$ Q = \frac{i}{2}\bigoplus _{k=1}^n\begin{bmatrix} 0 & -1\\ 1 & 0 \end{bmatrix} $$
Let me formulate the optimization problem:
$$ \min_{B\in {\Re}^{2n\times 2n}} \lVert A - B \rVert_{F}^2 ~~~~~{\rm s.t.}~~~ B + Q \geq 0.$$
-> Therefore, we have a convex optimization problem. Convex optimization problems are very well understood and there is software available to solve them.
For software, I would recommend you the cvx-interface for Matlab http://cvxr.com/cvx/. For further reading on convex optimization see http://web.stanford.edu/~boyd/cvxbook/.