Essentially, this problem is to generate integers $n,s,a_1,\dots,a_n$ such that $n\ge1$ and
$$(n-1)s^2=a_1^2+\dots+a_n^2.\tag{1}$$
To do this, let $k:=\lfloor n/4\rfloor$ and take any nonnegative integers $t_1,\dots,t_k$ such that
$$(n-1)s^2=t_1+\dots+t_k.\tag{2}$$
For each $j\in[k]:=\{1,\dots,k\}$, by Lagrange's four-square theorem, there exist integers $a_{j1},\dots,a_{j4}$ such that
$$t_j=\sum_{i=1}^4 a_{ji}^2,$$
so that
$$(n-1)s^2=\sum_{j=1}^k\sum_{i=1}^4 a_{ji}^2.\tag{3}$$
The latter expression is the sum of $4k\le n$ squares of nonnegative integers. Complementing this sum by the sum of $n-4k$ squares of $0$, we get representation (1) -- for any given natural $n$ and integer $s$.
This is illustrated by the the following image of a Mathematica notebook, finding a representation (1) for $n=15$ and $s=5$;
$$(15-1)5^2=4^2 + 0^2 + 8^2 + 6^2 + 10^2 + 0^2 + 4^2 + 2^2 + 5^2 + 0^2 + 8^2 +
5^2 + 0^2 + 0^2 + 0^2.$$
Of course, the $a_i$'s in (1) are the deviations of the sample values from the sample mean. Previously, I forgot to take into account that the sum of the $a_i$'s must of course be $0$.
$\newcommand\ep\epsilon$One way to get that is to try to attach "signs" $\ep_i\in\{-1,1\}$ to the $a_i$'s so that $\sum_{i=1}^m\ep_i a_i=0$. I think usually this will be possible to do when $\sum_{i=1}^m a_i$ is even, as is the case with the above example (continued below). Otherwise, repeat with other $t_1,\dots,t_k$ in (2) and/or with other instances of the $a_{j1},\dots,a_{j4}$'s.
The problem of the existence of "balancing" signs $\ep_i\in\{-1,1\}$ is obviously equivalent to the so-called partition problem, which is easily solved for not too big values $n$ and $\sum_{i=1}^m a_i$ in view of the simple recurrence relation, whose application to the particular $a_i$'s considered in the mentioned Mathematica notebook is illustrated here:
This again confirms that for our particular $a_i$'s "balancing" signs $\ep_i\in\{-1,1\}$ exist.
The problem of actually finding an appropriate partition (which is equivalent to finding "balancing" signs $\ep_i\in\{-1,1\}$) was solved by Korf.
For our particular $a_i$'s there actually are $18$ different "balancing" sign assignments $(\ep_i)$, not counting sign assignments to the $0$'s.
Another way to make the sum of the deviations $0$ is as follows. If $(n-1)s^2$ is even, find integers $b_1,\dots,b_{4l}$ such that
$$(n-1)s^2/2=b_1^2+\dots+b_{4l}^2$$
(cf. (3)), where $l:=\lfloor n/8\rfloor$. Then, letting
$$(a_1,\dots,a_n):=(b_1,\dots,b_{4l},-b_1,\dots,-b_{4l},0,\dots,0),$$
we have both (1) and the balance condition $\sum_{i\in[n]}a_i=0$ satisfied. Of course, one can also replace $(a_1,\dots,a_n)$ by any permutation of this $n$-tuple.