Let $\mathcal{I}$ be the integral in question. We have
$$
\begin{align}
\mathcal{I} &= \int_{0}^{\frac{\pi}{2}}\arctan\left(\frac{2}{\cos^{2}x}\right)\,dx \\
&\overset{\cos x \mapsto x}=\int_{0}^{1}\frac{\arctan\left(\frac{2}{x^{2}}\right)}{\sqrt{1-x^{2}}}\,dx \\
&= \int_{0}^{1}\frac{\arctan\left(1+x\right)+\arctan\left(1-x\right)}{\sqrt{1-x^{2}}}\,dx \tag{1}\\
&= \int_{0}^{1}\frac{\arctan\left(1+x\right)}{\sqrt{1-x^{2}}}dx+\int_{-1}^{0}\frac{\arctan\left(1+x\right)}{\sqrt{1-x^{2}}}\,dx \\
&= \int_{-1}^{1}\frac{\arctan\left(1+x\right)}{\sqrt{1-x^{2}}}\,dx\,. \\
&\overset{x\mapsto\cos x}= \int_{0}^{\pi}\arctan\left(1+\cos x\right)\,dx\,.
\end{align}
$$
Note that in $(1)$ we used the formula $\arctan\left(a\right)+\arctan\left(b\right)=\arctan\left(\frac{a+b}{1-ab}\right)$ where $ab<1$. Proof here.
Next, we use the following integration by parts shown below.
$$
\begin{array} {|c|c|}
\hline
u=\arctan\left(1+\cos x\right) &dv=dx \\
\downarrow &\downarrow \\
du=-\frac{\sin x}{1+\left(1+\cos x\right)^{2}}\,dx &v=x \\
\hline
\end{array}
$$
We have
$$
\require{cancel}
\mathcal{I} = \cancelto{0}{x\arctan\left(1+\cos x\right)\Big|_{0}^{\pi}} + \int_{0}^{\pi}\frac{x\sin x}{1+\left(1+\cos x\right)^{2}}\,dx \overset{x\mapsto 2\arctan x}= 8\int_{0}^{\infty}\frac{x\arctan x}{x^{4}+2x^{2}+5}\,dx\,.
$$
This next section will prove
$$
\int_{0}^{\infty}\frac{x\arctan x}{x^{4}+2x^{2}+5}\,dx=\frac{\pi}{8}\operatorname{arccsc}\phi
$$
where $\phi$ is the Golden Ratio.
PROOF. Define a holomorphic function $f: \mathbb{C}\,\setminus \left(\left\{it \mid t \in [1,\infty)\right\} \cup \left\{z_1,z_2,z_3,z_4\right\}\right) \longrightarrow \mathbb{C}$ where
$$z \mapsto \frac{z\ln\lvert 1+iz\rvert+iz\arg\left(1+iz\right)}{z^{4}+2z^{2}+5}$$
and its first-order poles are
$$
\begin{align}
z_{1}&:=5^{1/4}i\exp\left(-\frac{i}{2}\arctan2\right)\\
z_{2}&:=5^{1/4}i\exp\left(\frac{i}{2}\arctan2\right)\\
z_{3}&:=-5^{1/4}i\exp\left(-\frac{i}{2}\arctan2\right)\\
z_{4}&:=-5^{1/4}i\exp\left(\frac{i}{2}\arctan2\right)\,.\\
\end{align}
$$
We employ the usual principal branch of $\arg$, namely $-\pi < \arg\left(1+iz\right) \leq \pi$. The branch cut of $f$ lies vertically on the imaginary axis; since the principal branch of $\arg z$ lies on the negative real axis, we have $1+iz = -t \iff z = i(t+1)$ for positive $t$. Letting $z$ be a function of $t$, we see that $z(t) = i(t+1)$. Making $R$ sufficiently large, the contour to integrate over is $\mathcal{C}$, defined as the union of sets below:
$$
\begin{align}
C_1 &:= [0,R] \\
C_2 &:= \left\{Re^{-it} \in \mathbb{C} \mid t \in \left[0,\frac{\pi}{2}\right]\right\} \\
C_3 &:= \left\{it \in \mathbb{C} \mid t \in [-R,0]\right\}\,. \\
\end{align}
$$
Here is a visual of the contour with the rainbow phase plot.
$$
\text{Quarter-Pie Contour $\mathcal{C}$ Traveling Clockwise}
$$

We write the contour integral over $\mathcal{C}$ as
$$
\oint_{\mathcal{C}}f = \int_{C_1}f+\int_{C_2}f+\int_{C_3}f\,.
$$
Equating the imaginary part on both sides, then applying $R\to\infty$, we have
$$
\lim_{R\to\infty}\Im\oint_{\mathcal{C}}f = \lim_{R\to\infty}\Im\int_{C_1}f+\lim_{R\to\infty}\Im\int_{C_2}f+\lim_{R\to\infty}\Im\int_{C_3}f\,.
$$
Rewriting the first integral, we have
$$
\lim_{R\to\infty}\Im\int_{C_1}f = \lim_{R\to\infty}\Im\int_{0}^{R}\frac{x\ln\left|1+ix\right|+ix\arg\left(1+ix\right)}{x^{4}+2x^{2}+5}\,dx = \int_{0}^{\infty}\frac{x\arctan x}{x^{4}+2x^{2}+5}\,dx\,. \\
$$
Evaluating the second integral, we bound its modulus like this:
$$
\begin{align}
\left|\Im\int_{C_{2}}f\right| &\leq \left|\int_{C_{2}}f\right| \\
&= \left|\int_{0}^{\frac{\pi}{2}}f\!\left(Re^{-it}\right)d\!\left(Re^{-it}\right)\right| \\
&= \left|\int_{0}^{\frac{\pi}{2}}\frac{Re^{-it}\left(\ln\left|1+iRe^{-it}\right|+i\arg\left(1+iRe^{-it}\right)\right)}{\left(Re^{-it}\right)^{4}+2\left(Re^{-it}\right)^{2}+5}\,dt\right| \\
&\leq \int_{0}^{\frac{\pi}{2}}\left|\frac{Re^{-it}\left(\ln\left|1+iRe^{-it}\right|+i\arg\left(1+iRe^{-it}\right)\right)}{\left(Re^{-it}\right)^{4}+2\left(Re^{-it}\right)^{2}+5}\right|\,dt \\
&= \int_{0}^{\frac{\pi}{2}}\frac{\left|Re^{-it}\ln\left|1+iRe^{-it}\right|+iRe^{-it}\arg\left(1+iRe^{-it}\right)\right|}{\left|R^{4}e^{-4it}+2R^{2}e^{-2it}+5\right|}\,dt \\
&\leq \int_{0}^{\frac{\pi}{2}}\frac{\frac{R}{2}\ln\left(R^{2}\cos^{2}t+\left(1+R\sin t\right)^{2}\right)+\pi R}{R^{4}-2R^{2}-5}\,dt
\end{align}
$$
The last inequality comes from using the Triangle Inequalities and knowing that the principal argument is bounded above by $\pi$.
Using the Squeeze Theorem, we eventually get
$$
\lim_{R\to\infty}\left|\Im\int_{C_2}f\right| = 0\,,
$$
which means the original integral over $C_2$ goes to $0$ as well.
Rewriting the third integral, we have
$$
\begin{align}
\Im\int_{C_3}f &= \Im\int_{-R}^{0}f(it)\,d(it) \\
&= \Re\int_{-R}^{0}\frac{it\ln\left|1-t\right|-t\arg\left(1-t\right)}{t^{4}-2t^{2}+5}\,dt \\
&= \int_{-R}^{0}\frac{t\arg\left(1-t\right)}{t^{4}-2t^{2}+5}\,dt \\
&= 0\,. \\
\end{align}
$$
Rewriting the integral over $\mathcal{C}$, we use the famous Cauchy's Residue Theorem to evaluate the residue at the simple pole $z_4$ like so:
$$
\require{enclose}
\begin{align}
\Im\oint_{\mathcal{C}}f &= -\Im 2\pi i\mathop{\mathrm{Res}}_{z=z_4}f(z) \\
&= -\Im 2\pi i\lim_{z\to z_4}\enclose{downdiagonalstrike}{(z-z_4)}\frac{z\ln\left|1+iz\right|+iz\arg\left(1+iz\right)}{\left(z-z_{1}\right)\left(z-z_{2}\right)\left(z-z_{3}\right)\enclose{updiagonalstrike}{\left(z-z_{4}\right)}} \\
&= -\Im 2\pi i\frac{z_{4}\ln\left|1+iz_{4}\right|+iz_{4}\arg\left(1+iz_{4}\right)}{\left(z_{4}-z_{1}\right)\left(z_{4}-z_{2}\right)\left(z_{4}-z_{3}\right)} \\
&= \frac{\pi}{8}\operatorname{arccsc}\phi\,. \\
\end{align}
$$
The last line is numerically verified here, you would need to just click on the the closed form under "Result" to see its numerical value.
We gather these four results together to get
$$
\int_{0}^{\infty}\frac{x\arctan x}{x^{4}+2x^{2}+5}\,dx=\frac{\pi}{8}\operatorname{arccsc}\phi\,. \tag*{$\blacksquare$}
$$
Finally, we have
$$
\bbox[0px,#0bddcd,border:3px solid #06897f]{\bbox[10px,#ffffff,border:3.3px outset #0bddcd]{\int_{0}^{\frac{\pi}{2}}\arctan\left(\frac{2}{\cos^{2}x}\right)\,dx=\pi\operatorname{arccsc}\phi
}}
$$
and we're done. :)