It makes no difference on $k$ (assuming the spring is ideal).
Start with the potential energy of the spring $\frac{1}{2}kz^2$ alone and write the equation of motion
\begin{align}
m\ddot{z}=-kz\, ,
\end{align}
with solution
\begin{align}
z(t)=A\cos(\omega t)+B\sin(\omega t)\, ,\qquad \omega^2 = k/m\, .
\tag{1}
\end{align}
Now add the effect of gravity to get the net potential:
\begin{align}
U=\frac{1}{2}kz^2+ mgz\, .
\end{align}
The equation of motion is now
\begin{align}
m\ddot{z}=-kz-mg\, .
\end{align}
You can then verify by direct substitution that
\begin{align}
z(t)=A\cos(\omega t)+B\sin(\omega t)+z_0\, ,\qquad z_0=mg/k \, ,\tag{2}
\end{align}
is the solution, with the same frequency $\omega$ as if there were not gravity. The solution has just been shifted by an amount $z_0$.
If gravity had an effect on the spring, it would have changed the frequency of oscillation of the system, since this frequency is always $\sqrt{k_{\small{eff}}/m}$, where $k_{\small{eff}}$ is the effective spring constant of the system.
Indeed it’s a common experiment in basic physics to compare the frequency of the mass-spring system arranged horizontally (where gravity has no effect) and vertically: to no surprise there is no change in frequency, and thus no change in the value of $k$ due to gravity.