When does glueing affine schemes produce affine/separated schemes?
There is a general criterion that explains when a gluing of two separated schemes is separated.
Proposition: Let $X_1, X_2$ be a separated $S$-schemes, $U_i$ open subschemes in $X_i$ (for $i=1, 2$), and $f:U_1 \to U_2$ an $S$-isomorphism. Then the $S$-scheme $X$ obtained as a gluing of $X_1$ and $X_2$ along the isomorphism $f$ is separated if and only if the ``diagonal'' morphism $$ U_1 \to X_1\times_S X_2 $$ is a closed immersion.
In the situation $U_1=\operatorname{Spec} A$ and $X_1=X_2=\operatorname{Spec} B$ are affine the criterion says that separtedness of $X$ is equivalent to surjectivity of the map $$ \phi:B\otimes_{\mathbf Z} B \to A $$ defined by $\phi(a\otimes a')=af^*(b)$.
Here are some thoughts in the case of gluing a DVR along an automorphism of its fraction field:
Setup: Let $A$ be a DVR with uniformizer $\pi$ and fraction field $K$, and let $\varphi : K \to K$ be a ring automorphism. Let $S$ be the gluing of two copies of $\operatorname{Spec} A$ along the automorphism of $\operatorname{Spec} K$ corresponding to $\varphi$.
On separatedness: I claim that $S$ is separated if and only if $\varphi(A) \not\subseteq A$. By Tag 01KP we have that $S$ is separated if and only if the ring map \begin{align} \mu_{\varphi} : A \otimes_{\mathbb{Z}} A \to K \end{align} sending $a_{1} \otimes a_{2} \mapsto a_{1} \cdot \varphi(a_{2})$ is surjective. If $\varphi(A) \not\subseteq A$, then $\mu_{\varphi}$ is surjective since the image of $\mu_{\varphi}$ is a subring of $K$ strictly larger than $A$. On the other hand, if $\varphi(A) \subseteq A$ then the image of $\mu_{\varphi}$ is $A$.
On affineness: EDIT: user "m.mor" proves in this answer that if $S$ is separated then it is affine. I don't have a complete answer. We may consider using Serre's criterion (e.g. Tag 01XF). Let $\mathcal{I} \subseteq \mathcal{O}_{S}$ be an ideal sheaf of $S$. By the Mayer-Vietoris sequence, we have that $\mathrm{H}^{1}(S,\mathcal{I}) = 0$ if and only if for all $e_{1},e_{2} \in \mathbb{Z}_{\ge 0}$ the addition map \begin{align} \alpha_{e_{1},e_{2},\varphi} : \pi^{e_{1}}A \oplus \pi^{e_{2}}A \to K \end{align} sending $(a_{1},a_{2}) \mapsto a_{1} + \varphi(a_{2})$ is surjective. Thus certainly if $\varphi(A) \subseteq A$ then $S$ is not affine. Here I tried some examples (e.g. $A = k[x]_{(x)}$ and the automorphism of $k(x)$ sends $x \mapsto \frac{1}{x}$, or $A = k[x,y]_{(x)}$ and the automorphism of $k(x,y)$ switches $x,y$) and the resulting glued schemes were affine (these examples generalize to Lemma 1 below). Another strategy would be to view everything with the $\pi$-adic topology and try to use Lemma 2 below, but I don't know whether $\varphi(A)$ is a dense subgroup of $K$.
Lemma 1: Let $A$ be a Dedekind domain with fraction field $K$. Suppose that $A$ has exactly two maximal ideals $\mathfrak{p}_{1},\mathfrak{p}_{2}$. Then for any $s_{1},s_{2} \in \mathbb{Z}_{\ge 0}$ the addition map \begin{align} \mathfrak{p}_{1}^{s_{1}}A_{\mathfrak{p}_{1}} \oplus \mathfrak{p}_{2}^{s_{2}}A_{\mathfrak{p}_{2}} \to K \end{align} sending $(a_{1},a_{2}) \mapsto a_{1}+a_{2}$ is surjective.
Proof: Since $A$ has finitely many maximal ideals, it is a PID. Let $\pi_{i}$ be a generator of $\mathfrak{p}_{i}$; then $K := A[(\pi_{1}\pi_{2})^{-1}]$ as $A$-algebras. Moreover $\pi_{1}^{e_{1}}-\pi_{2}^{e_{2}}$ is a unit for all $e_{1},e_{2} \ge 1$. As an $A$-module, $K$ is generated by the elements $1/\pi_{1}^{e_{1}}\pi_{2}^{e_{2}}$ for all $e_{1},e_{2} \ge 0$. We may assume that $e_{1},e_{2} \ge 1$. Then \begin{align} \textstyle \frac{1}{\pi_{1}^{e_{1}}\pi_{2}^{e_{2}}} = \pi_{1}^{s_{1}} \cdot (\frac{1}{\pi_{1}^{s_{1}+e_{1}}-\pi_{2}^{s_{2}+e_{2}}}) \frac{1}{\pi_{2}^{e_{2}}} + \pi_{2}^{s_{2}} \cdot (-\frac{1}{\pi_{1}^{s_{1}+e_{1}}-\pi_{2}^{s_{2}+e_{2}}}) \frac{1}{\pi_{1}^{e_{1}}} \end{align} so we have the desired result.
Lemma 2: Let $G$ be a topological group. Let $U$ be an open subgroup of $G$ and let $H$ be a dense subgroup of $G$. Then $G = UH$.
(I heard about this fact here.)