You can easily do that with {pNiceMatrix} of nicematrix.
In that environment, you have a built-in command \Block and you can fill a block with the color you want.
In order to show that this works even in presence of a background, I have put the environment {pNiceMatrix} in a {tcolorbox} (user121799's answer does not work with a background).
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{nicematrix,tikz}
\begin{document}
\begin{tcolorbox}
[\begin{pNiceMatrix}[margin]
\Block[fill=blue!40,rounded-corners]{4-4}{}
3 & -1 & -1 & -1 & 0 & 0 & 0 \
-1 & 1 & 0 & 0 & 0 & 0 & 0 \
-1 & 0 & \Block[fill=red!40,rounded-corners]{-}{}
2 & 0 & 0 & 0 & 0 \
-1 & 0 & 0 & 2 & -1 & 0 & 0 \
0 & 0 & -1 & 0 & 3 & -1 & -1 \
0 & 0 & 0 & -1 & -1 & 3 & -1 \
0 & 0 & 0 & 0 & -1 & -1 & 2
\end{pNiceMatrix}]
\end{tcolorbox}
\end{document}
You need several compilations (because nicematrix uses PGF/Tikz nodes).

You can use the key opacity (requires v. 6.22 of nicematrix).
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{nicematrix}
\begin{document}
\begin{tcolorbox}
[\begin{pNiceMatrix}[margin]
\Block[fill=blue!40,rounded-corners]{4-4}{}
3 & -1 & -1 & -1 & 0 & 0 & 0 \
-1 & 1 & 0 & 0 & 0 & 0 & 0 \
-1 & 0 & \Block[fill=red!80,opacity=0.5,rounded-corners]{-}{}
2 & 0 & 0 & 0 & 0 \
-1 & 0 & 0 & 2 & -1 & 0 & 0 \
0 & 0 & -1 & 0 & 3 & -1 & -1 \
0 & 0 & 0 & -1 & -1 & 3 & -1 \
0 & 0 & 0 & 0 & -1 & -1 & 2
\end{pNiceMatrix}]
\end{tcolorbox}
\end{document}

If you want the red block behind the blue one, this technic won't work. In that case, it's possible to use the \CodeBefore provided by {pNiceMatrix} in order to draw the colored rectangles with Tikz before the construction of the array (using Tikz nodes created by nicematrix in the matrix).
Once again, this works even with a background.
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{nicematrix,tikz}
\begin{document}
\begin{tcolorbox}
[\begin{pNiceMatrix}[margin]
\CodeBefore
\begin{tikzpicture}
\fill [red!40,rounded corners] (3-|3) rectangle (8-|8) ;
\fill [blue!40,rounded corners] (1-|1) rectangle (5-|5) ;
\end{tikzpicture}
\Body
3 & -1 & -1 & -1 & 0 & 0 & 0 \
-1 & 1 & 0 & 0 & 0 & 0 & 0 \
-1 & 0 & 2 & 0 & 0 & 0 & 0 \
-1 & 0 & 0 & 2 & -1 & 0 & 0 \
0 & 0 & -1 & 0 & 3 & -1 & -1 \
0 & 0 & 0 & -1 & -1 & 3 & -1 \
0 & 0 & 0 & 0 & -1 & -1 & 2
\end{pNiceMatrix}]
\end{tcolorbox}
\end{document}
