To simplify, I am going to make the problem linear in parameters. You have a structural-form equation for the outcome $y$, the intermediate outcome equation for $x$, and an independence assumption:
$$ \begin{align*} y_i &=\beta_1+\beta_t \cdot t_i + \beta_x \cdot x_i + \varepsilon_i \\ x_i &= \alpha_1+\alpha_t \cdot t_i + u_i \\
(t,x) & \perp \!\!\! \perp \varepsilon \\ \end{align*}$$
Plugging the second into the first gets you the reduced-form equation for the outcome:
$$ y_i = (\beta_1 + \beta_x \cdot \alpha_1) + (\beta_t +\beta_x \cdot \alpha_t) \cdot t_i + (\beta_x \cdot u_i + \varepsilon_i)
$$
You have two effects:
$$\begin{align*} \text{Total Effect: }& E[y \vert t=1]-E[y \vert t=0] = \beta_t +\beta_x \cdot \alpha_t \\ \text{Direct Effect: }& E[y \vert t=1,w]-E[y \vert t=0, w] = \beta_t \\ \end{align*}$$
You can use the reduced-form outcome equation to estimate the first, and you can use the structural-form equation to estimate the second. A difference of the two recovers the indirect effect.
Here's a toy example using Stata where the indirect effect dominates:
. clear
. sysuse auto, clear
(1978 Automobile Data)
. quietly reg price i.foreign
. estimates store rf
. quietly reg price i.foreign c.mpg
. estimates store sf
. suest rf sf
Simultaneous results for rf, sf
Number of obs = 74
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rf_mean |
foreign |
Foreign | 312.2587 696.9581 0.45 0.654 -1053.754 1678.271
_cons | 6072.423 428.2447 14.18 0.000 5233.079 6911.767
-------------+----------------------------------------------------------------
rf_lnvar |
_cons | 15.9902 .2260545 70.74 0.000 15.54714 16.43325
-------------+----------------------------------------------------------------
sf_mean |
foreign |
Foreign | 1767.292 599.3555 2.95 0.003 592.5771 2942.007
mpg | -294.1955 59.50419 -4.94 0.000 -410.8216 -177.5695
_cons | 11905.42 1343.753 8.86 0.000 9271.709 14539.12
-------------+----------------------------------------------------------------
sf_lnvar |
_cons | 15.6727 .2476991 63.27 0.000 15.18722 16.15818
------------------------------------------------------------------------------
. nlcom indirect_effect:[rf_mean]_b[1.foreign] - [sf_mean]_b[1.foreign]
indirect_e~t: [rf_mean]_b[1.foreign] - [sf_mean]_b[1.foreign]
---------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
----------------+----------------------------------------------------------------
indirect_effect | -1455.034 488.1763 -2.98 0.003 -2411.841 -498.2255
---------------------------------------------------------------------------------
If you don't care about the standard errors, this can be done with two separate regressions rather than Seemingly Unrelated Estimation.