It ultimately depends on the nature of the underlying data for your simulation to represent that. For instance, if you have some type of censored Poisson process what I will show won't make sense as is.
But, one way is to generate all possible permutations that meet your criteria (here there end up being 627 possible permutations that meet {10 choose 2} + {10 choose 3} ... + {10 choose 5}). And then you can sample at random from that greater choice set.
import itertools as it
import numpy as np
np.random.seed(10)
# Lets create the whole sets of possible permutation lists
res = []
zr = np.zeros(10)
for i in range(2,6):
for p in it.combinations(range(10),i):
on = zr.copy()
on[list(p)] = 1
res.append(on.copy())
resnp = np.stack(res,axis=0)
# Now lets sample 1000 from this list
total_perms = resnp.shape[0]
samp = np.random.choice(total_perms,1000)
res_samp = resnp[samp]
# Check to make sure this is OK
np.unique(res_samp.sum(axis=1),return_counts=True)
If you had observed data, you could generate probabilities from that observed data and feed into the p probability argument for np.random.choice.
In this scenario, there are more permutations for the 10 choose 5 than there are for the 10 choose 2, if you want those types of scenarios to happen with equal probability, you would set the sum of the probabilities for the 10 choose 2 scenarios to be equal to that of the 10 choose 5.