Connect 3-port and 1-port devices defined by S-matrices
I found an answer in Computer-Aided Design of Microwave Circuits by K. C. Gupta (see chapter 11, section 11.2.3). One can also look at this article referenced by Gupta.

WARNING: Indexing does not match with original post.

Let's see the figure. There are three n-port networks:


A is defined by
\$
\mathbf{S}^A =
\left[
\begin{array}{ll}
s_{11,A} &amp; s_{12,A} \\
s_{21,A} &amp; s_{22,A}
\end{array}
\right]
\$
matrix;
B is defined by
\$
\mathbf{S}^B =
\left[
\begin{array}{ll}
s_{11,B} &amp; s_{12,B} &amp; s_{13,B} \\
s_{21,B} &amp; s_{22,B} &amp; s_{23,B} \\
s_{31,B} &amp; s_{32,B} &amp; s_{33,B}
\end{array}
\right]
\$
matrix;
C is defined by \$\mathbf{S}^C = s_{11,C}\$ matrix.


These networks are connected to each other as follows. The resulting matrix
\$
\mathbf{S}_P =
\left[
\begin{array}{ll}
s_{11} &amp; s_{12} \\
s_{21} &amp; s_{22}
\end{array}
\right]
\$
of the whole 2-port network (with ports 1 and 2, which are circled in schematic) should be defined relative to \$\mathbf{S}^A\$, \$\mathbf{S}^B\$ and \$\mathbf{S}^C\$ matrices.



Let's number each port (оf subnetworks) with numbers from 1 to 6 as shown on figure.
Ports with numbers 1 and 4 are external (\$p\$-ports) and other ones are internal (\$c\$-ports).
Green colored numbers is for port numbering of corresponding subnetwork. Red and blue colored number is for internal ports, which are connected to each other.

The wave equation for all components is:
$$
\left[
\begin{array}{l}
\mathbf{b}_p \\
\mathbf{b}_c
\end{array}
\right] =
\left[
\begin{array}{ll}
\mathbf{S}_{pp} &amp; \mathbf{S}_{pc} \\
\mathbf{S}_{cp} &amp; \mathbf{S}_{cc}
\end{array}
\right]
\cdot
\left[
\begin{array}{l}
\mathbf{a}_p \\
\mathbf{a}_c
\end{array}
\right],
$$
where \$\mathbf{S}_{pp}\$, \$\mathbf{S}_{pc}\$, \$\mathbf{S}_{cp}\$, \$\mathbf{S}_{cc}\$ are submatrices of the network.

Internal connections can be represented as wave equation
$$
\mathbf{b}_c = \mathbf{\Gamma} \mathbf{a}_c,
$$
where \$\mathbf{\Gamma}\$ is connection matrix.

The \$\mathbf{S}_p\$-matrix is defined as:
$$
\mathbf{S}_p =
\mathbf{S}_{pp} +
\mathbf{S}_{pc}
\left(
\mathbf\Gamma - \mathbf{S}_{cc}
\right)^{-1}
\mathbf{S}_{cp}.
$$

For specified network submatrices can be defined as
$$
\mathbf{S}_{pp} =
\left[
\begin{array}{cc}
s_{11,A} &amp; 0 \\
0 &amp; s_{22,B}
\end{array}
\right];~
\mathbf{S}_{pc} =
\left[
\begin{array}{cccc}
s_{12,A} &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; s_{23,B} &amp; s_{21,B}
\end{array}
\right];\\
\mathbf{S}_{cp} =
\left[
\begin{array}{cc}
s_{21,A} &amp; 0 \\
0 &amp; 0 \\
0 &amp; s_{32,B} \\
0 &amp; s_{12,B}
\end{array}
\right];~
\mathbf{S}_{cc} =
\left[
\begin{array}{cccc}
s_{22,A} &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; s_C &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; s_{33,B} &amp; s_{31,B} \\
0 &amp; 0 &amp; s_{13,B} &amp; s_{11,B}
\end{array}
\right].
$$

And the whole wave equation is
$$
\left[
\begin{array}{c}
b_1 \\
b_4 \\\hline
b_2 \\
b_6 \\
b_5 \\
b_3
\end{array}
\right] =
\left[
\begin{array}{cc|cccc}
s_{11,A} &amp; 0 &amp; s_{12,A} &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; s_{22,B} &amp; 0 &amp; 0 &amp; s_{23,B} &amp; s_{21,B} \\\hline
s_{21,A} &amp; 0 &amp; s_{22,A} &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; 0 &amp; s_C &amp; 0 &amp; 0 \\
0 &amp; s_{32,B} &amp; 0 &amp; 0 &amp; s_{33,B} &amp; s_{31,B} \\
0 &amp; s_{12,B} &amp; 0 &amp; 0 &amp; s_{13,B} &amp; s_{11,B}
\end{array}
\right] \cdot
\left[
\begin{array}{c}
a_1 \\
a_4 \\\hline
a_2 \\
a_6 \\
a_5 \\
a_3
\end{array}
\right].
$$

The connection equation is
$$
\left[
\begin{array}{c}
b_2 \\ b_6 \\ b_5 \\ b_3
\end{array}
\right] =
\left[
\begin{array}{cccc}
0 &amp; 0 &amp; 0 &amp; 1 \\
0 &amp; 0 &amp; 1 &amp; 0 \\
0 &amp; 1 &amp; 0 &amp; 0 \\
1 &amp; 0 &amp; 0 &amp; 0
\end{array}
\right] \cdot
\left[
\begin{array}{c}
a_2 \\ a_6 \\ a_5 \\ a_3
\end{array}
\right]
$$

And at last
$$
\mathbf{S}_p =
\left[
\begin{array}{cc}
s_{11,A} &amp; 0 \\
0 &amp; s_{22,B}
\end{array}
\right] +\\
\left[
\begin{array}{cccc}
s_{12,A} &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; s_{23,B} &amp; s_{21,B}
\end{array}
\right] \cdot
\left[
\begin{array}{cccc}
-s_{22,A} &amp; 0 &amp; 0 &amp; 1 \\
0 &amp; -s_C &amp; 1 &amp; 0 \\
0 &amp; 1 &amp; -s_{33,B} &amp; -s_{31,B} \\
1 &amp; 0 &amp; -s_{13,B} &amp; -s_{11,B}
\end{array}
\right]^{-1} \times\\
\left[
\begin{array}{cc}
s_{21,A} &amp; 0 \\
0 &amp; 0 \\
0 &amp; s_{32,B} \\
0 &amp; s_{12,B}
\end{array}
\right]
$$

That is all.

PS: I hope someone do a grammar check.