A naïve way to do this might be to divide X up into some number of bins. Then weight each sample in your data by 1/(number of samples where X falls in the same bin as this one). That will give you a distribution where X "looks flat" in that it has a flat histogram.
Comments
If you want a non-parametric estimator, there are approaches...
https://journals.aps.org/pre/abstract/10.1103/PhysRevE.69.066138