I read a science fiction story once about such a mega-city on an island about the size of Manhattan. Only it was more vertical than horizontal.
The buildings towered miles into the sky and it was the lower class people who lived in the upper reaches. Only the elite were allowed to be on the lower levels, where there was more infrastructure and things to do.
Most people would live their entire lives at the 500 story level and above and some of these buildings reached 1,000 stories tall. There were terraces where people could get fresh air and maybe grow some tomatoes or play some volleyball. The buildings were also connected to each other at various levels so you could walk between them.
But to get to the lower levels, you had to improve your social standing. Otherwise, as the population increased, they just kept building higher and higher and kept pushing the poorer people to the top.
Beneath a Steel Sky
https://en.wikipedia.org/wiki/Beneath_a_Steel_Sky
1994 PC adventure game. Mega city in Australia where the poor are living at the top and the rich are on the ground level. The protagonist is kidnapped and crashes at the top of a skyscraper and has to find their way down
It was a good game.