It is impossible to calculate an answer to your question, therefore I expect that you won't get any hard science answers to your specific question. However, it is possible for experts to give you calculations about some limiting factors.
As far as I know, there is no theoretical maximum number of habitable planets in a star system. Star systems with habitable planets probably become rarer as the number of habitable planets increases, so that it becomes statistically less and less likely to find star systems with more habitable planets and finding a star system with more than a specific number probably becomes extremely unlikely.
Nobody has actually discovered any habitable planets outside our solar system, since with present technology it is impossible to tell if an exoplanet is habitable or not.
But astronomers have discovered a few roughly Earth sized planets orbiting within the habitable zones of their stars, and consider those planets to be potentially habitable planets. More such planets will be discovered. Sometime in the future each of those potentially habitable planets will be classified as either uninhabitable or habitable as more evidence about their conditions is discovered.
At the present it is unknown how common habitable planets are and thus what proportion of star systems have even one habitable planet. And of course systems with one habitable planet are probably more common than systems with two habitable planets that are probably more common than solar systems with three habitable planets and so on.
Sometime in the future astronomers may have detected a lot of habitable exoplanets and be able to calculate what percentage of star systems have one habitable planet each, what percentage of star systems have two habitable planets each, what percentage of star systems have three habitable planets each, and so on.
And then they could calculate an upper limit for habitable planets in a single star system likely to be found among a thousand star systems, or among a million star systems, and so on. They should be able to calculate the largest number of habitable planets in a single star system likely to be found in the Milky Way Galaxy, our galaxy, with its hundreds of billions of star system.
They could even calculate the largest number of habitable planets in a single star system likely to be found in the entire observable universe with its hundreds of billions of galaxies.
But nobody will ever be able to calculate the largest number of habitable planets in a single star system likely to be found in the entire universe that actually exists, stretching far beyond the observable universe, until scientists have a much more accurate idea of the size of the actual universe.
And of course calculations based on the relative frequencies of observed star systems with one, two, three, four, etc. habitable planets are likely to be more and more inaccurate for star systems with higher numbers of habitable planets, so calculations for the frequency of star systems with seven, or eight, or nine, etc. habitable planets would be increasingly inaccurate.
Here are some rough estimates of the frequency of solar systems with various numbers of habitable planets. These estimates are totally arbitrary just to illustrate the way it might possibly work:
I system with 1 habitable planet for every 10 stars.
1 system with 2 habitable planets for every 100 stars.
1 system with 3 habitable planets for every 1,000 stars.
1 system with 4 habitable planets for every 10,000 stars.
1 system with 5 habitable planets for every 100,000 stars.
1 system with 6 habitable planets for every 1,000,000 stars.
1 system with 7 habitable planets for every 10,000,000 stars.
So a statistically average random group of 10,000,000 stars should have 1 system with 7 habitable planets, 10 systems with 6 habitable planets, 100 systems with 5 habitable planets, 1,000 systems with 4 habitable planets, 10,000 systems with 3 habitable planets, 100,000 systems with 2 habitable planets, and 1,000,000 systems with 1 habitable planet.
There would be a total of 1,111,111 systems with one or more habitable planets and 8,888,889 star systems without any habitable planets in the group of 10,000,000 star systems.
That is just an example of an arbitrary distribution of star systems with various numbers of habitable planets.
Thus every habitable planet in an entire galaxy would have to be discovered for an accurate answer to the question of what is the largest number of habitable planets in an single star system in that galaxy.
When I was kid, I loved old science fiction stories where there were several habitable planets in Earth's solar system, even though the probability of that seemed dubious to me then and seemed dubious to astronomers even when those stories were written.
Venus, Earth, and Mars were all habitable for humans in many of those old science fiction stories.
Many stories even had other habitable worlds in the solar system. Every planet from Mercury to Pluto was habitable for humans and/or had native life in at least one old science fiction story that I remember. The giant planets Jupiter, Saturn, Uranus, & Neptune had solid surfaces that Earthmen could walk on and were habitable in some old stories. Habitable natural satellites included the Moon (though usually in the past), Jupiter's large moons Io, Europa, Ganymede, and Callisto, Saturn's moon Titan and maybe others, and Neptune's large moon Triton.
I once asked a question about what science fiction story had the most naturally habitable woulds in our solar system. https://scifi.stackexchange.com/questions/94599/which-science-fiction-work-had-the-most-habitable-worlds-in-our-solar-system1
As far back as 1964 an answer of sorts was provided to your question. Stephen Dole's Habitable Planets for Man (1964, 2009) was a detailed analysis of the factors influencing planetary habitability and the probability of a planet being habitable.
According to Dole, there was a limit to how densely packed the orbits of planets could be in a star system, due to gravitational interactions between the star and the planets, which would tend to make planets orbiting too close to others collide or be ejected from the system. I believe the size of a planet's exclusive zone would be larger the lower the star's gravitational force on it is, and lower the higher the star's gravitational force on the planet is.
According to Dole, the Sun's stellar habitability zone is about half full of the exclusion zones of planets and about half empty. So if the planets were packed as close as they could possibly be, with the edges of their exclusion zones just touching, within the Sun's stellar habitability zone, there could be about twice as many planets in the habitability zone as there actually are.
Assuming that there are three planet's within the Sun's stellar habitability zone, a star exactly like the Sun, with a spectral type G2V, with the same size circumstellar habitable zone, might have five, six or seven planets within its circumstellar habitable zone although that would be a rare occurrence. And among stars that have five, six, or seven planets within their stellar habitability zones, some would have all five, six or seven of those planets actually habitable, although that would be rare.
A more massive star than the Sun would be more luminous and thus its stellar habitability zone would be wider, and could contain more planets.
But Dole pointed out a problem with more massive and thus more luminous stars. More massive stars fuse hydrogen at a faster rate than is proportional to their mass. So they run out of fuel sooner than less massive stars do, and when they run out of hydrogen fuel they leave the main sequence stage of stellar existence and swell up into red giant stars and eventually shrink into white dwarf stars, changes that should kill off any life on their habitable planets and make those planets uninhabitable, even when those changes don't totally destroy those planets. The more massive stars also go though even worse stages like becoming novas and supernovas, which are even more likely to totally destroy their planets.
Dole estimated that a planet would not become habitable for humans until it was at least three billion (3,000,000,000) Earth years old, and that would probably be rare because Earth didn't become habitable for humans until it was a lot older than that. So a star would have to be capable of remaining in the main sequence stage for at least three billion (3,000,000,000) Earth years in order to be capable of having any habitable planets.
According to astrophysical calculations, stars more massive than spectral class F can not remain calm main sequence stars for as much as three billion (3,000,000,000) Earth years. Dole believed that even the most massive and luminous type F stars would not remain on the main sequence for three billion (3,000,000,000) Earth years. Dole decided that the most massive stars capable of remaining on the main sequence for that long were either F2 stars (less massive than F0 stars) or F5 stars (less massive than F2 stars), I forget which.
This was highly disappointing. It meant that most of the most famous stars in the heavens were incapable of remaining main sequence stars long enough for their planets to become habitable. Unless super advanced civilizations moved already habitable planets into orbit around those stars or terraformed the planets already orbiting those stars.
So I imagined that possibly a small percentage of F type stars would have the maximum number of planets in their habitable zones, and also be over 3,000,000,000 Earth years old, and also have all of their planets in the habitable zone actually habitable for humans. Presumably a very small proportion of them.
And I figure that if there were two identical F type stars orbiting closely enough - maybe five or ten million miles apart - around each other, they could have habitable planets orbiting both of them in a habitable zone whose limits would be 1.41 times the limits of a habitable zone for only one of those F type stars. A planet that orbits around both stars in a binary system is said to have a circumbinary or P-type orbit.
Astronomers have now discovered planets orbiting in P-type or circumbinary orbits around binary stars.
And for decades I believed that such a star system might possibly have as many as ten or twelve planets habitable for humans and that such desirable star systems would be very, very, rare.
Wikipedia has an article called Circumstellar habitable zone.
The width, or the inner and outer limits, of a star's circumstellar habitable zone or "Goldilocks Zone", are usually given in Astronomical Units or AUs.
An Astronomical Unit, or AU, is the average distance between Earth and The Sun. It is defined as exactly 149,597,870,700 meters or 149,597,870.7 kilometers, or 92,955,807 miles.
If a star has X times the luminosity of The Sun, its circumstellar habitable zone should have X times the inner and outer limits, and thus total width, of the Sun's circumstellar habitable Zone. So to estimate the size of a star's circumstellar habitable zone one would just find out how luminous it is compared to the Sun and then multiply or divide the size of the Sun's circumstellar habitable zone by that amount.
Except that there isn't much agreement about the size of the Sun's circumstellar habitable zone.
The Wikipedia article "Circumstellar habitable zone" has a section with a table listing various estimates of the inner or outer edges, or both, of the Sun's circumstellar habitable zone.
According to the table, Dole estimated that the Sun's circumstellar habitable zone extended from 0.725 to 1.24 AU, with a total width of 0.515 AU.
Later studies have suggested highly different inner or outer limits or different total widths.
Some of those estimates may have been for planets habitable by humans, and others may have been for planets habitable for liquid water using organisms even if not habitable for humans, explaining some but not all of the differences.
In recent decades, over 4,000 planets in other stars systems have been discovered, including many examples of more than one planet orbiting the same star. And many systems with two or more exoplanets have widely different orbits than those in our Solar System.
The star with the widest spaced planets known is PTFO-8-8695, also known as CVSO 30. CVSO 30 c is about 662 AU farther out than CVSO 30 b, and its orbit has about 78,998 times the semi-major axis of the orbit of CVSO 30 b.
On the other extreme, Kepler-70c has an orbit with a semi-major axis only 0.0016 AU (about 240,000 km) wider than the semi-major axis of the orbit of Kepler-70b.
During closest approach, Kepler-70c would appear 5 times the size of the Moon in Kepler-70b's sky.
The system with the smallest known ratio between the semi-major axis of the orbits of two planets is Kepler-36. The semi-major axis of the orbit of Kepler-36c is only 1.1127 times the semi-major axis of the orbit of Kepler-36b.
I don't know why Dole was wrong about the minimum possible spacing between planetary orbits, or how much closer stable planetary orbits could be spaced than in those examples.
I do not know whether the physics of planetary orbits is more dependent on the relative spacing or the absolute spacing of planetary orbits to determine how close two stable planetary orbits can be.
The narrowest habitable zone for the Sun is that given by:
Hart, M. H. (1979). "Habitable zones about main sequence stars". Icarus. 37 (1): 351–357.
Since the outer edge of Hart's habitable zone is only 1.0631 times as far as the inner edge, if planetary orbits had a ratio of 1.1127 to that of the next inner orbit there would be room for only one stable planetary orbit within Hart's habitable zone.
Hart's habitable zone has an inner edge at 0.95 AU and an outer edge at 1.01 AU, with a total width of only 0.06 AU. If planetary orbits were spaced 0.0016 AU apart, there could theoretically be 37 or 38 stable planetary orbits within such a habitable zone, though it might be extremely rare for even one planet to orbit in such a narrow habitable zone.
The most common definition of the Sun's habitable zone is that of:
Kasting, James F.; Whitmire, Daniel P.; Reynolds, Ray T. (January 1993). "Habitable Zones around Main Sequence Stars". Icarus. 101 (1): 108–118.
Kasting's habitable zone is much wider than Hart's. Kasting offered a conservative habitable zone, between 0.95 AU and 1.37 AU, and an optimistic habitable zone, between 0.84 AU and 1.67 AU.
The outer edge of Kasting's conservative habitable zone is 1.4421 times the distance of the inner edge. Assuming that a planet orbits at the inner edge, and that the planetary orbits are each spaced at the minimum ratio of 1.1127 times the orbit of the next planet:
The first planet would orbit at 0.9500 AU.
The second planet would orbit at 1.0570 AU.
The third planet would orbit at 1.1761 AU.
The fourth planet would orbit at 1.3087 AU.
The fifth planet would orbit at 1.4562 AU, which would be outside of Kasting's conservative habitable zone.
So assuming that the minimum possible ratio between the orbits of successive planets is 1.1127, there is room for four stable planetary orbits within Kasting's conservative habitable zone.
The outer edge of Kasting's optimistic habitable zone is 1.9880 times the distance of the inner edge. If a planet orbits at 0.84 AU and the planetary orbits all have a ratio of 1.1127 of the orbit of the next inner planet:
The first planet would orbit at 0.8400 AU.
the second planet would orbit at 0.9937 AU.
The third planet would orbit at 1.0400 AU.
The fourth planet would orbit at 1.1572 AU.
the fifth planet would orbit at 1.4327 AU.
the sixth planet would orbit at 1.5942 AU.
the seventh planet would orbit at 1.7738 AU, which would be outside of Kasting's optimistic habitable zone.
So assuming that the minimum possible ratio between the orbits of successive planets is 1.1127, there is room for six stable planetary orbits within Kasting's optimistic habitable zone.
Note that if the minimum possible spacing between stable planetary orbits is determined by their relative spacing, the absolute dimensions of a star's circumstellar habitable zone will not matter. Only the ratio between the inner and the outer borders of the star's circumstellar habitable zone will matter for how many stable planetary orbits could possibly be within that star's habitable zone.
Kasting's conservative habitable zone is 0.42 AU thick. Assuming that the minimum spacing between stable planetary orbits is dependent on their absolute spacing and not the relative spacing, and assuming that the minimum possible absolute spacing is 0.0016 AU, there is room for about 262 to 263 stable planetary orbits within Kasting's conservative habitable zone.
Kasting's optimistic habitable zone is 0.83 AU thick. Assuming that the minimum spacing between stable planetary orbits is dependent on their absolute spacing and not the relative spacing, and assuming that the minimum possible absolute spacing is 0.0016 AU, there is room for about 518 to 519 stable planetary orbits within Kasting's optimistic habitable zone.
If the minimum spacing between planetary orbits is dependent on their absolute spacing and not the relative spacing, the absolute size of a star's habitable zone and not the relative size of it will determine the maximum possible number of stable planetary orbits in it. Thus I suppose that if there is a binary system of F5 stars, with a combined habitable zone much larger than that of the Sun, there could be maybe as many as about 1,000 stable planetary orbits in the combined habitable zone of the two stars.
Of course possibly having as many as 1,000 stable planetary orbits in the habitable zone of a system doesn't mean that 1,000 Earth like planets will form in that system in the habitable zone or form somewhere else in the system and migrate to the habitable zone. But it does indicate a sort of a theoretical possible maximum of 1,000 habitable planets orbiting in the combined habitable zone of a system of binary F5 stars.
Of course there are are many spectral type A, B, & O stars which have much larger circumstellar habitable zones than my example of a binary system of F5 stars. Thus such stars can theoretically have stable orbits for thousands of planets in their habitable zones - if the minimum spacing between stable planetary orbits is dependent on their absolute spacing and not the relative spacing.
But according to current astrophysical calculations, spectral type A, B, & O stars cannot possibly remain main sequence stars for long enough to any planets they might have to become habitable for humans or develop advanced native lifeforms. The only way such stars could have any planets interesting at all - except for possibly mining - would be if an advanced civilization terraformed their planets to make them habitable for advanced lifeforms, or if an advanced civilization moved older planets with advanced life from other star systems and put those planets in orbit around those stars.
One way to check these calculations is the configurations of various families of exoplanets orbiting the same star as they are discovered.
According to the Wikipedia List of potentially habitable exoplanets TRAPPIST-1 has four planets orbiting in its circumstellar habitable zone which thus are potentially habitable planets.
TRAPPIST-1e orbits at 1.3153 time the orbit of TRAPPIST-1d.
TRAPPIST-1f orbits at 1.3150 times the orbit of TRAPPIST-1e.
TRAPPIST-1g orbits at 1.25 times the orbit of TRAPPIST-1f.
If the minimum possible spacing between stable planetary orbits is determined by their relative spacing, and the minimum relative spacing was 1.25 times, there could be two stable planetary orbits within Kasting's conservative habitable zone and three stable planetary orbits within Kasting's optimistic habitable zone.
If the absolute spacing of planetary orbits and not their relative spacing, determined the minimum possible distance between stable planetary orbits, a lot more planets could fit within a habitable zone.
Kasting's conservative habitable zone is 0.42 AU wide, and Kasting's optimistic habitable zone is 0.83 AU wide. Since an AU is 149,597,870.7 kilometers, Kasting's conservative habitable zone is 62,831,105.69 Kilometers wide, and Kasting's optimistic habitable zone is 124,166,232.7 kilometers wide.
Since TRAPPIST-1g orbits 3,680,000 kilometers beyond the orbit of TRAPPIST-1d, there are three orbital gaps in 3,680,000 kilometers, or one orbital gap per 1,226,666.66 kilometers. So there should be about 51 or 52 stable planetary orbits in Kasting's conservative habitable zone, and about 101 or 102 stable planetary orbits in Kasting's optimistic habitable zone.
There have been many questions about hypothetical habitable moons of giant exoplanets. You might want to look at the answers to some of those questions for references to other sources, such as this question:
Temperature and climate "under" the gas giant in a tidally locked moon9
The article "Exomoon Habitability Constrained by Illumination and Tidal heating" by Rene Heller and Roy Barnes Astrobiology, January 2013, discusses factors affecting the habitability of exomoons.
And you should go to the PlanetPlanet site and look at the section on ultimate solar systems with the largest number of habitable planets. Some of those ultimate solar systems are so improbable that they would have to be constructed by advanced civilizations since they could never form naturally.
And after reading this post you should be as uncertain about the theoretical maximum possible number of habitable planets in a solar system as I am.