It would also have to comply with noise ordinances. So if neighbors can hear those scary gunshots, then it would probably be in violation.
You have a simple solution? Mufflers are for bad guys.
No instead you need to sound proof the whole place, not diminish the report of the gun.
Any projectiles leaving the property would likely result in serious penalties or criminal charges, as well as media attention of the psycho with X guns raided by police on charges of ___, _____, ______, (several that don't even apply initially thrown in for good measure as is typical.)
The guy would be known to the public as a crazy psycho before he even got to tell his side once he did anything that brought legal attention.
However if it was sound proofed, had a good backstop for the calibers used, and nobody around was aware, and there was no accidents like self inflicted wounds at the range, it could go both undetected and be legal in some places.
If you were going to research constructing such a thing and the legalities in your jurisdiction you would probably want to do so in a manner that does not let everyone know you will have a gun range in your home.
What does a billion residents have to do with it being lawful or not?
While not a specific legal answer, generally population density leads to greater restrictions on freedom to more easily manage the masses, and because people want to better manage each other and impose what they think others should be doing.
People start to feel entitled to decisions not just about how they live, but about every detail of the masses they are in close proximity to. You get ordinances and home owner's associations as the norm that for example tell you what height the grass can be, what colors you are allowed to paint, what types of vehicles are allowed in driveways, whether you can alter your fence or plant a tree, etc
Likewise they will be into every detail on what and how you can possess and use various objects, especially those they associate with high risk and/or violence. Guns, airguns, things that look too much like a gun, stun guns, pepper spray, pocket knives, pointy sticks, etc
NJ has the highest population density in the nation, and lives up to the expectation of having some of the greatest number of restrictions on its residents.