Closed - form expression for the finite sum $\sum _{k=0}^{n-1} (-1)^k \sec \left(\frac{\pi\, k}{n}+\frac{\pi }{2 \ n}\right)$

For an approximation, it seems that for $n=2,6,10,\cdots$ $$S_n=\sum _{k=0}^{n-1} (-1)^k \sec \left(\frac{(2 k+1)\pi }{2 n}\right)\sim 1+n$$ and that for $n=4,8,12,\cdots$ $$S_n=\sum _{k=0}^{n-1} (-1)^k \sec \left(\frac{(2 k+1)\pi }{2 n}\right)\sim 1-n$$

For illustration

$$\left( \begin{array}{ccc} n & 1+n & S_n\\ 2 & 3 & 2.82843 \\ 6 & 7 & 6.96953 \\ 10 & 11 & 10.9882 \\ 14 & 15 & 14.9939 \\ 18 & 19 & 18.9963 \\ 22 & 23 & 22.9975 \end{array} \right)$$

$$\left( \begin{array}{ccc} n & 1-n & S_n\\ 4 & -3 & -3.06147 \\ 8 & -7 & -7.01795 \\ 12 & -11 & -11.0083 \\ 16 & -15 & -15.0047 \\ 20 & -19 & -19.0030 \\ 24 & -23 & -23.0021 \end{array} \right)$$


Define the sequence of numbers for all positive even integer $n$ $$ a_n := \sum _{k=0}^{n-1} (-1)^k \sec \left(\frac{\pi \, k}{n}+\frac{\pi }{2\,n}\right). \tag{1} $$ The sequence has an asymptotic power series expansion in powers of $\,1/n\,$ $$ a_n \sim -n\,i^n + \sum_{k=0}^\infty \frac{E_k^2}{k!} \left(\frac{\pi\, i}{2\, n}\right)^k. \tag{2} $$ All terms with odd $\,k\,$ in the summation are zero since the Euler number $\,E_k=0.\,$ The series is asymptotic so the partial sums start to converge but after a certain point they diverge to infinity. However, the Wikipedia article on divergent series lists several methods of summing divergent series and one or more of them may be of use here.

Note that Euler numbers are OEIS sequence A122045 with e.g.f. $\text{sech}(x),\,$ but the sequence of its squares $\,E_k^2\,$ is not in OEIS and so it is unlikely for its e.g.f. to have a simple closed form, but it still may be possible. The Wikipedia article 1-1+2-6+24-120+... gives hope that this may be the case.

The Wolfram language code I used for exploring $q$-digamma based on the expression of the OP.

ClearAll[ank, a, ax, qd, f];
ank[n_,k_] := (-1)^k Sec[Pi k/n + Pi/2/n];
a[n_?EvenQ] := a[n] = Sum[ ank[n, k], {k, 0, n-1}];
ax[n_, t_] := -n I^n + Sum[ EulerE[k]^2 (I Pi/2/n)^k/k!, {k, 0, 2*t}];
qd[z_, q_] := QPolyGamma[z, q]; (* q-digamma = psi_q(z) *)
f[n_, q_:0] := Module[{q1 = If[q==0, Exp[2 Pi I/n], q]},
    n/Pi (qd[(1-n)/4, q1] - 2 qd[(1+n)/4, q1] + qd[(1+3n)/4, q1])];

Notice that evaluating the $q$-digamma in f[n] at roots of unity blows up and Mathematica will leave it unevaluated. You can verify this by evaluating f[n,Exp[2 Pi I/n]x] where $x$ is close to $1$. Also, notice that f[n]//FunctionExpand//N does not evaluate to a numerical value for even integer values of $\,n\ge12.\,$