Initial idea
How about: model the number of lawyers in each town as the prediction of a Bayesian model? The actual number of lawyers is used as the input.
You can draw stochastically from the resulting model, which means some towns with no lawyers will occasionally be drawn with a lawyer, and some with three lawyers will occasionally be drawn as having no lawyers.
Alternatively, you could work with the resulting output as an estimate of the number of lawyers. So a town with no lawyers might show with an estimate of 0.2 lawyers, and a town with one lawyer might show with an estimate of maybe 0.22 lawyers.
Actual usable algorithm
In practice, because you have so many towns, what you can do is a slight nuance on this: create a single global model, per profession, which predicts a probability distribution over the number of lawyers in a town, given the number of people in the town, and a set of parameters:
$$
p(N_{\text{lawyer}} \mid N_{\text{town}}, \theta) = f(\theta, N_{\text{town}})
$$
Using this, and given your data $\mathcal{D} = \{ \mathcal{D}_1, \mathcal{D}_2, \dots, \mathcal{D}_n \}$, we can obtain the probability of the data given the parameters:
$$
p(\mathcal{D} \mid \theta) = \prod_{i=1}^n p(\mathcal{D}_i \mid \theta)
$$
Then use Bayesian inference on this to find the posterior distribution over $\theta$:
$$
p(\theta \mid \mathcal{D}) = \frac{p(\mathcal{D} \mid \theta)\,p(\theta)}
{\int_{-\infty}^\infty p(\mathcal{D}, \theta)\, d\theta}
$$
... which can be estimated using eg VAE, https://arxiv.org/abs/1312.6114
or you could use a MAP estimation, which avoids handling the intractable marginalization for the evidence:
$$
\theta^* = \text{argmax}_{\theta} p(\mathcal{D} \mid \theta)\,p(\theta)
$$
Once you have either $\theta$ or a probability distribution over $\theta$, well $\theta$ is pretty much the solution to your problem directly, since it is the parameters of a probability distribution showing how the number of people having a certain profession varies with the size of the town. But you can then do things like:
- find the total number of lawyers, by integrating over all towns (eg numerically); or
- estimate the number of lawyers, holding the size of the town fixed