I am not sure if the following result is known or an equivalent result is known. I think, if the result holds then this could be used an elementary number theory exercise.
Let $k \in \mathbb{Z} \setminus \{0\}$ be fixed. For $n\in \mathbb{N} $ , let $A_{n,k}=[a^{nk}_{ij}]$ be a $n\times n$ matrix such that $$ a^{nk}_{ij}= \begin{cases} i & i= j \\ k & \text{otherwise} \end{cases} $$ As a matrix, $A_{n,k}$ has the following form $$ A_{n,k}=\left[ \begin{matrix} 1 & k & \ldots & k\\ k & 2 & \ldots & k\\ \vdots & \vdots & \ddots & \vdots\\ k & k &\ldots & n \end{matrix} \right] $$ Conjecture: Let $n\geq |k|$. If $k$ is odd , then $n$ is prime number if and only if $$|{\det(A_{n,k})}|\equiv -|{k}| \mod n $$ and if $k$ is even then $n$ is prime if and only if $$|{\det(A_{n,k})}|\equiv -k \mod n .$$
It is easy to figure out for $k\geq 1$ , $\det A_{n,k}=(k-1)!(n-k)!$ . Thus, for $k=1$, you basically get $\det A_{n,1}=(n-1)!$ which is equivalent to Wilson's theorem. For $k>1$, we get $n$ prime iff $(k-1)!(n-k)!\equiv (-1)^k \mod n.$ I wrote a Matlab code to check and it seems to be true. Does anyone have a counterexample or know how to prove it? The Gauss's generalization of Wilson's theorem seem to be related to this but that only considers(as far as I know) integers less than and that are co-prime to $n$.
P. S. For $k=-1$, I calculated the determinant in a non trivial way and got $\det A_{n,-1}={n!\big(n-(1+n)(\mathcal{H}_n-1)\big)}$ where $\mathcal{H}_n$ is the $n$th harmonic number so the determinant of this matrix seem to relate the $n$-harmonic number with prime numbers as well.