I know you asked for standard matrix environments, but I suggest nicematrix
.

If you want additional space for the delimiters (so the lines don't touch them) you can include [extra-margin=3pt]
in the following code:
\documentclass{article}
\usepackage{nicematrix, tikz}
\begin{document}
\[
B_1\oplus B_2\oplus B_3=
\begin{pNiceMatrix}%[extra-margin=3pt]
\CodeBefore
\tikz \draw(1-|3) |- (4-|last) (3-|1) -| (last-|4);
\Body
1&2&0&0&0&0\\
1&1&0&0&0&0\\
0&0&3&0&0&0\\
0&0&0&1&2&1\\
0&0&0&1&2&3\\
0&0&0&1&1&1
\end{pNiceMatrix}.
\]
\end{document}
To clarify the (i-|j)
notation: If tikz
is loaded (note that nicematrix
does not automatically load tikz
) then (i-|j)
is the intersection of the ith horizontal rule with the jth vertical rule (whether or not the rules are actually drawn). The 1st horizontal rule is above row 1; the 1st vertical rule is left of column 1. There is also position i.5
which is halfway between i
and i+1
(useful for striking out rows or columns). The last position has the alias last
.
These positions can be accessed using CodeBefore
or CodeAfter
(see the excellent nicematrix
manual for details) just as one would use a node in TikZ. So in the CodeBefore
, a tikzpicture can, for example, include \draw (1-|2) -- (3-|4);
for a diagonal line, or \draw (1-|2) -| (3-|4);
to draw horizontally then vertically.
amsmath
? Otherwise, have a look at thenicematrix
package. In any case: Please show what you tried so far. This can help others in helping you solving your issue.