In upcoming (now on arXiv:2205.08623) joint work with Jarod Alper, Jack Hall and Daniel Halpern-Leistner:
Artin algebraization for pairs with applications to the local structure of stacks and Ferrand pushouts
we prove more generally the existence of pushouts of affine morphisms along closed immersions in the category of (quasi-separated) algebraic stacks (Thm. 1.8). This in particular implies that Milnor squares are pushouts in the category of (quasi-separated) algebraic stacks. Let me sketch how this is proved:
Let $X=\operatorname{Spec} B$ and $Y=\operatorname{Spec} A$ and similarly for the primes so we have a cartesian square:
$\require{AMScd}$
\begin{CD}
X' @>f'>> Y'\\
@V g' V V @VV g V\\
X @>>f> Y
\end{CD}
with $g$, $g'$ closed immersions.
By assumption, this is co-cartesian in the category of affine schemes.
To show that this is co-cartesian in the category of algebraic stacks, let $Z$ be an algebraic stack together with maps $u\colon X\to Z$ and $v\colon Y'\to Z$ and a $2$-isomorphism $ug'\cong vf'$. We can replace $Z$ with an open quasi-compact neighborhood of the images of $u$ and $v$ and assume that $Z$ is quasi-compact.
Let $p\colon Z_1\to Z$ be an affine smooth presentation. Consider the pull-backs along $u$, $ug'\cong vf'$ and $v$ and call these $X_1\to X$, $X'_1\to X'$ and $Y'_1\to Y'$. The easiest case is if $Z$ has affine diagonal. Then $p$ is affine and $X_1$, $X'_1$, $Y'_1$ are also affine. Then we can take the pushout of the three affine schemes resulting in $Y_1\to Y$. This gives us a map $Y_1\to Z_1\to Z$. One then observes that $Y_1\to Y$ is smooth (flatness is [Fer, Thm 2.2 (iv)] and finite presentation can be proven similarly and smoothness then follows by considering fibers). Then take $X_2=X_1\times_X X_1$ etc. We obtain two maps $Y_2\rightrightarrows Y_1\to Z_1\to Z$. Since $Y_2$ also is a pushout in the category of affine schemes (they are stable under flat base change by [Fer, Thm 2.2 (iv)]) these two maps coincide (*). By descent, we obtain a map $Y\to Z$.
(*) It remains to show that any two maps $Y\to Z$ fitting in the diagram are isomorphic up to unique 2-isomorphism. For this, one takes two maps and pull-back the diagonal of $Z$. This is then turned into an existence question. Again, if the diagonal is affine, it is immediate.
When the diagonal is not affine, then the $X_1$, $X'_1$ and $Y'_1$ above are merely algebraic spaces. One can take an étale affine presentation of $X_1$ and pull this back to $X'_1$. The crucial step is then to extend this to an étale presentation of $Y'_1$. This is where the Artin algebraization alluded to in the title comes in. It is also needed when you want to construct the pushout $Y$ of a diagram $X\leftarrow X'\rightarrow Y'$ of algebraic stacks (affine / closed immersion).
Edit: In [TT], the case where $\Delta_Z$ is (ind-)quasi-affine is handled. The crucial result is [TT, Thm 5.7/5.8] which in the setup above proves that $Y_1$ exists when $X_1$ is (ind-)quasi-affine. This settles the case when $Z$ is an algebraic space or a Deligne–Mumford stack with separated diagonal. The case where $f$ is finite/integral is easier and treated in [Fer] and [R, Thm. A.4]. Also see MO question Ferrand pushouts for algebraic stacks.
[Fer] Daniel Ferrand, Conducteur, descente et pincement, Bull. Soc. Math. France 131 (2003), no. 4, 553–585.
[R] David Rydh, Compactification of tame Deligne–Mumford stacks, preprint, https://people.kth.se/~dary/tamecompactification20110517.pdf
[TT] Michael Temkin and Ilya Tyomkin, Ferrand pushouts for algebraic spaces, Eur. J. Math. 2 (2016), no. 4, 960–983.