I think what you are asking is, if you have a a set of four numbers, you want to generate some data which has (approximately) these four numbers for the mean, variance, skew and kurtosis.
A Python solution is given in this great answer on stack overflow.
The solution linked to above may be helpful in achieving this.
For example if the set of four numbers we are trying to achieve are (0,1,-1,3) then it works quite well.
I ran the code linked above, generated a sample, and for this sample achieved [-0.012865049352413248 0.9854758243633666 -1.0212929276152714 2.8670673702318163]
respectively for mean, variance, skew and kurtosis - so quite close to (0,1,-1,3).
It is worth noting that this won't necessarily work with any set of four numbers, chosen arbitrarily.
For example running it with (50,4,-1,12) I got [49.827147444660625 5.961898303494179 -0.29452022237194114 3.1324664040689862]. Notice that the PDF (in blue) is taking values below 0 (and notice the CDF in orange is decreasing).

The following note is from the statsmodel documentation for pdf_mvsk
In the Gram-Charlier distribituion it is possible that the density
becomes negative. This is the case when the deviation from the normal
distribution is too large.
Code: I took my code directly from the answer above. To produce the plots I just plotted (x,y) and (x,yy).
One suggestion in the comments was to look at the Pearson distributions. You may have some success adapting the following.
We can specify the mean, skew and standard deviation(hence variance). Suppose we want to achieve [50,4,-1] for the mean, variance and skew.
import scipy.stats as ss
import numpy as np
#Note scale is standard deviation in scipy stats
sample = ss.pearson3.rvs(loc=50, scale=2, skew=-1, size=1000)
print(np.mean(sample),
np.var(sample),
ss.skew(sample),
ss.kurtosis(sample))
Output: 49.96935451394343 4.268526621056802 -1.005394332195325 1.3883750132508892
Close to what we were hoping for.
If you use R, I think more options are available to you in the PearsonDS package. If you must use Python, it is possible to use R within Python to generate your data samples, using the rpy2 module.
Probability distributions are defined with parameters. The skewness and kurtosis of a random variable will just be a function of those parameters.
Take a gamma distribution with a mean and variance already set by you (this means the two parameters $(\alpha,\beta)$ are defined). Once you have defined those parameters, the skewness and kurtosis are already defined. You cannot change those.
– statsplease Apr 10 '22 at 05:09x = sample_from_some_distribution(m1, m2, m3, m4, n). – Joseph Apr 11 '22 at 00:43