It is fairly easy to draw a dotted line from the north to the south coordinate of a fitted node:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{fit,shapes.geometric,calc,matrix,math}
\begin{document}
\begin{tikzpicture}
\matrix(m) [matrix of nodes, row sep=1ex, column sep=1ex, nodes in empty cells, nodes={draw, shape=rectangle,minimum height=5ex, anchor=center, minimum width=5ex},ampersand replacement=&] {
a & 1 & x & o & 2 \
b & & & & 3 \
c & & & & y \
d & & & & 4 \
e & 5 & v & p & w \
};
\node[fit= (m-2-2.north west) (m-4-4.south east), draw=red,inner sep=0ex] (x) {};
\draw[loosely dotted] (x.north) -- (x.south);
\end{tikzpicture}
\end{document}
It would be much better if I could fit a custom dot pattern by choosing the size and spacing of the dots especially if this was predefined as a style. This style could be
part of the \node[fit...] command instead of requiring a \draw command.


fitnode with a pattern or to draw only a line like in the current answer or to draw the contour of thefitnode with a customized pattern? – CarLaTeX Nov 21 '21 at 19:21