This is only a fun answer. I am trying out LoopSpace's great update of the tikzmark package, which has now a command in that I was always looking for: \tikzmarknode. And it just works. (Yes, using tikz here may be an overkill, as I said, this is just for fun and to learn something new.) EDIT: Moved the brackets away from the boxes, big thanks to @manooooh!
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{tikzmark,fit}
\newcommand\bigzero{\makebox(0,0){\text{\huge0}}}
\begin{document}
\begin{equation}
\left(~\begin{matrix}
\tikzmarknode{1A}{0}&1\\
1&\tikzmarknode{1B}{0}&&&&\bigzero\\
&&\tikzmarknode{2A}{0}&1\\
&&1&\tikzmarknode{2B}{0}\\
&&&&\ddots\\
&\bigzero&&&&\tikzmarknode{3A}{0}&1\\
&&&&&1&\tikzmarknode{3B}{0}
\end{matrix}~\right)
\begin{tikzpicture}[overlay, remember picture]
\foreach \X in {1,2,3}
{\node[inner sep=1pt,draw,fit=(\X A)(\X B)]{};}
\end{tikzpicture}
\end{equation}
\end{document}

matrix. Maybe using someting like\left(\;\begin{matrix}...\end{matrix}\;\right)would be ok? – manooooh Sep 09 '18 at 20:54\fboxonly solution by placing the 2x2 matrices in\fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-) – Sep 09 '18 at 20:58fboxes would be fantastic! – manooooh Sep 09 '18 at 21:02\fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-) – Sep 09 '18 at 21:08~~after the1which adds a bit of space after the1, thus seeming to push the0further out due to the centring of the matrix entries. – Andrew Stacey Sep 11 '18 at 18:39