For evaluation purposes assume that $a>0$ and is not an even number.
The approach you mentioned can be used to evaluate the integral.
Integrate the function $$f(z) = 8a \, \frac{z^{2}}{4z^{2}+a^{2}\pi^{2}} \frac{1}{\sinh^{2}(z)} $$ around a rectangular contour with vertices at $z= \pm x$, $z= \pm x + i (2N+1) \pi/2$, where $x \ge 0$ and $N \in \mathbb{N}$.
Letting $x \to \infty$, the integrals along the left and right sides of the contour vanish because $\sinh(z)$ grows exponentially as $\Re(z) \to \pm \infty$.
And on the line $x + i(2N+1)\pi/2$, $x \in \mathbb{R}$, $\frac{1}{\sinh^{2}(z)} = - \frac{1}{\cosh^{2}(x)}$, which is independent of $N$.
Letting $N \to \infty$, the integral along the top of the contour goes to $$8a \int_{-\infty}^{\infty} \frac{1}{4}\frac{1}{\cosh^{2}(x)} \, \mathrm dx = 4a .$$
(The dominated convergence theorem allows us to move the limit inside the integral after we parametrize the top of the contour. )
Therefore, we have $$\int_{-\infty}^{\infty} f(x) \, \mathrm dx +4a = 2 \pi i \left(\operatorname*{Res}_{z = a \pi i /2} f(z) + \sum_{n=1}^{\infty} \operatorname*{Res}_{z=n \pi i} f(z) \right). $$
The residue at $z= a \pi i/2$ is $\frac{- a^{2} \pi i}{2 \, {\color{red}{\sin}^{2}}(\tfrac{a \pi}{2})} $.
(If $a$ is even, then the pole at $z= a \pi i /2$ is a triple pole.)
And since $$ \begin{align} f(z) &= 8a \left(\frac{n^{2}}{4n^{2}-a^{2}}+ \frac{2in a^{2}}{(4n^{2}-a^{2} ) \pi} (z-n \pi i) +O \left((z-n \pi i)^{2}\right) \right) \left(\frac{1}{(z- n \pi i)^{2}} + O(1) \right) \\ &= 8a \left(\frac{n^{2}}{4n^{2}-a^{2}} \frac{1}{(z-n \pi i)^{2}} + \frac{2na^{2}i}{(4n^{2}-a^{2})^{2} \pi } \frac{1}{z- n \pi i} + O(1)\right), \end{align}$$ it follows that $$\operatorname*{Res}_{z = n\pi i} f(z) = \frac{16n a^{3}i}{(4n^{2}-a^{2})^{2}}. $$
Using the series definition for trigamma function along with the recurrence relation for the trigamma function, we have $$ \begin{align} \sum_{n=1}^{\infty} \operatorname*{Res}_{z=\pi n i} f(z) &= 16 a^{3} i \sum_{n=1}^{\infty} \frac{n}{(4n^{2}-a^{2})^{2}} \\ &= \frac{2 a^{2}i}{\pi} \sum_{n=1}^{\infty} \left(\frac{1}{(2n-a)^{2}} - \frac{1}{(2n+a)^{2}} \right) \\ &= \frac{a^{2} i}{2\pi} \sum_{n=0}^{\infty} \left(\frac{1}{(n+1-\frac{a}{2})^{2}}- \frac{1}{(n+1+\frac{a \pi}{2})^{2}} \right) \\ &= \frac{a^{2}i}{2 \pi} \left(\psi_{1} \left(1-\frac{a}{2} \right)- \psi_{1} \left(1+ \frac{a}{2} \right) \right) \\&= \frac{a^{2}i}{2 \pi} \left(\psi_{1} \left(1- \frac{a}{2} \right)- \psi_{1} \left(\frac{a}{2} \right) + \frac{4}{a^{2}}\right), \end{align}$$
which agrees with the result from Mathematica.
Therefore, using the reflection formula for the trigamma function, we have $$ \begin{align} 8a \int_{-\infty}^{\infty} \frac{x^{2}}{4x^{2}+a^{2} \pi^{2}} \frac{1}{\sinh^{2}(x)}\, \mathrm dx &= a^{2} \psi_{1} \left(\frac{a}{2} \right) - a^{2} \psi_{1} \left(1- \frac{a}{2} \right) -4 + a^{2}\pi^{2} \csc^{2} \left(\frac{a \pi}{2} \right) -4a \\ &= 2a^{2} \psi_{1} \left(\frac{a}{2} \right) -4a -4, \end{align} $$ which agrees with Svyatoslav's result.
This result should hold even if $a$ is even.