Short Answer:
The question and answers seem to ignore one important factor in the ability of planets and other worlds to retain atmosphere.
Escape velocity.
The escape velocity of a world depends on the mass, radius, and average density of that. At the present time a minimum mass of 0.12 Earth mass seems to be considered necessary, but not sufficient, for a planet to retain a significant atmosphere for a long time.
Long Answer.
Planets with higher surfaces gravities usually have higher escape velocities.
Planets with higher escape velocities usually have higher surface gavities.
But different formulas are used to calculate the surface gravity and the escape velocity of a world. They do not change at the same rate as each other with different planetary masses and diameters.
If the question asks aboutjplanets retaining atmosphere in order to be habitable for life, it should be mentioned that there are different types of habitability.
For example, there is habitability for humans beings. Planets habitable for human beings should be a subset of planets on which some organisms found on Earth could survive, which should be a subset of planets with liquid water where some lifeforms similar to some Earth lifeforms could survive, whichou could be a subset of planets where beings with hypothetical alien biochemestries might possibly survive if there actually can be life using those hypotheical biochemestries.
Here is a link to a scientific discussion of planetary habitability for humans, Habitable Planets for Man Stephen H. Dole, 1964:
https://www.rand.org/content/dam/rand/pubs/commercial_books/2007/RAND_CB179-1.pdf
On pages 13 to 19 Dole considers human requirements for atmosphere, including minimum needs for a few gases and maximum limits for them and for many other gases.
To summarize then, the atmosphere of a habitable planet must contain oxygen with an inspired partial pressure of between 60 and 400 millimeters of mercury and carbon dioxide with a partial pressure roughly between 0.05 and 7 milllimeersof mercury. In addition, the partial pressure of the inert gases must be below certain specified limits and the other toxic gases must not be present in more than trace amounts. Some nitrogen must be present so that nitrogen in combined form can find its way into plants.
Since a human habitable planet must have liquid water, there must also be some water vapor in the atmosphere.
Dole presented a table giving the time for an atmosphere to escape with various ratios betgween the escape velocity of a planet and the root-mean-square velocity of air particles in the escape layer of the atmosphere, table 5 on page 35.
If the escape velocity is one or two times the root-mean-square velocity of the gases, the planet will lose them instantly. If the escape velocity is three times, it can hold the gases for a few weeks. If the escape velocity is four times, the planet can hold the gases for several thousand years. If the escape velocity is five times, the planet can hold the gases for about 100 million years. If the escape velocity is six times, the planet can hold the gases infinitely long.
Dole sums it up:
If a planet is to be able to capture a gas, the planetary escape velocity must be three or four times the root-mean-square velocity; for a planet to retain a gas permenently, the escape velocity must be about five or six times the root-mean-squae velocity.
On pages 54 to 58 Dole calculates the minimum mass necessary for a planet to retain an oxygen-rich atmosphere. The temperature, and thus the velocity, of oxygen molecules and atoms in the exosphere or escape layer of the atmosphere is important to the planet's ability to retain oxygen.
On page 54 Dole considered it possible for a habitable planet with a habitable surface temperature range to have temperatures in its exosphere as low as 1000 degress K (276.85 C or 1340.33 F).
However, if we take as a rough approximation that maximum exosphere temperatures as low as 1000 K are not incompatable with the required surface condiitons of a habitable planet, then the escape velocity of the smallest planet capable of retaining atomic oxygen may be as low as 6.25 kilometers per second (5 X 1.25). Going back to figure 9, this may be seen to correspond to a planet with a mass of 0.195 Earth mass, a radius of 0.63 Earth radius, and a surface gravity of 0.49 g.
Dole considered such a small planet capable of retaining an oxygen atmopshere but not capable of producing one, and then when on to estimate the inimum mass for a planet that could produce an oxygen atmosphere.
0.63 of Earth's radius of 6,371 kilometers or 3,959 miles would 4,013.73 kilometers or 2,494.17 miles, and the diameter of that planet would be twice the radius, of course - 8,027.46 kilometers or 4,988.34 miles.
Since Dole wrote a lot has been discovered about the surface temperatures of various world's in our solar system, and about the temperatures in the exospheres or escape layers of the atmosphere's of those worlds which have atmospheres.
So it is possible that modern estimates might change Dole's view that an exopshere temperature of a habitable planet could be as low as 1000 degress K (276.85 C or 1340.33 F).
Figure 9 on page 31 gives the relationship between the mass of terrestrial type planets and their radius, surface gravity, and escape velocity. Today we have more accurate information about the masses and radii of some solar system planets, and we have some information about the masses and radii of terrestrial type planets in other star systems.
So together, those two factors could make the minimum mass of a planet capable of retaining an oxygen rich atmosphere different from what Dole calculated.
Here is a link to a 2013 article discussing the potential habitability of hypothetical planetary mass exomoons of giant planets orbiting in the circumstellar habitable zones of other stars:
https://arxiv.org/ftp/arxiv/papers/1209/1209.5323.pdf
In this case habitabiity means teh more general case of habitablity for lifeforms which require liquid water and not the more specific cases of habitablity for humans.
The mass range of a hypothetical habitable exomoon is discussed on pages 3 & 4.
A minimum mass of an exomoon is required to drive a magnetic shield on a billion-year timescale (Ms ≳ 0.1M⊕,
Tachinami et al. 2011); to sustain a substantial, long-lived atmosphere (Ms ≳ 0.12M⊕, Williams et al. 1997; Kaltenegger
2000); and to drive tectonic activity (Ms ≳ 0.23M⊕, Williams et al. 1997), which is necessary to maintain plate tectonics and
to support the carbon-silicate cycle. Weak internal dynamos have been detected in Mercury and Ganymede (Kivelson et al.
1996; Gurnett et al. 1996), suggesting that satellite masses > 0.25M⊕ will be adequate for considerations of exomoon
habitability. This lower limit, however, is not a fixed number. Further sources of energy – such as radiogenic and tidal
Heller & Barnes (2013) – Exomoon habitability constrained by illumination and tidal heating
3
4 Maintained by Robert Jacobson, http://ssd.jpl.nasa.gov.
heating, and the effect of a moon’s composition and structure – can alter our limit in either direction. An upper mass limit is
given by the fact that increasing mass leads to high pressures in the moon’s interior, which will increase the mantle viscosity
and depress heat transfer throughout the mantle as well as in the core. Above a critical mass, the dynamo is strongly
suppressed and becomes too weak to generate a magnetic field or sustain plate tectonics. This maximum mass can be placed
around 2M⊕ (Gaidos et al. 2010; Noack & Breuer 2011; Stamenković et al. 2011). Summing up these conditions, we expect
approximately Earth-mass moons to be habitable, and these objects could be detectable with the newly started Hunt for
Exomoons with Kepler (HEK) project (Kipping et al. 2012).
The sources for a minimum mass of 0.12 Earth mass for a planet or moon to retain a substantial atmosphere for long time are given as;
Williams, D. M., Kasting, J. F., Wade, R. A. 1997, Nature, 385, 234
Kaltenegger, L. 2000, ESA Special Publication, 462, 199
So someone can look up those articles to see the basis of their calculations.
So it appears that a minimum mass of 0.12 Earth mass is necessary for a planet to retain a dense atmosphere for a long time.
And it is also important for a planet to have a strong enough magnetosphere to defect most charged particles from the solar wind and prevent them from knocking off atmospheric particles. Except for an exomoon orbiting within the magnetosphere of a giant planet, of course.
So having a high enough mass and escape velocity partially depends of the temperature and thus velocity of the air particles in the exosphere of the planet (r or moon). The closer it is to the star, and the hotter the star is, the hotter the planet's exosphere will be.
The farther the planet is from the star, the cooler its exosphere will be, and the smaller the planet can be and retain a dense atmosphere.
But you don't want the planet to be so far away for the star and so cold that its atmosphere freezes out.
And a planet should also have a strong enough magnetosphere to divert most charged particles in the solar wind. The closer the planet is to the star, and the more active the star is, the stronger the magnetosphere will have to be, and vice versa.
And from what I have read on the subject, it seems rather difficult to predict how strong the magnetosphere of a world will be. I think as a general rule, The more massive a world is, and the faster it rotates, the more likely it will be to have a strong magnetosphere.
But as far as I know there is no formula to calculate how strong the magnetosphere of a world will be from its mass and its rotation rate.