The imagined scenario is of a small city built inside of a chasm that draws most of its water from an aquifer or underground river. The place and time in which the scenario takes place is Earth and roughly around the year 2100 A.D. While surface cities enjoy the advanced technology that one would imagine populates the world, this particular semi-subterranean city is an unofficial haven for society's rejects and the disillusioned and therefore lags behind technologically speaking and frequently must rely on primitive forms of tech to survive. That brings me to this question of water wheels. Could waterwheels generate enough electricity to accommodate, or at least fortify as a secondary source, the energy needs of a city of say 50,000? How large and/or how many would be required? Keep in mind the energy would mostly be diverted to growing and maintaining sources of food and vital industry such as medicine and communication. Thank you.
Probably not Roman or post-Roman overshot, breast, or undershot (i.e. classic) water wheels, but what about reasonably modern hydro power installations?
First, you would need to define the energy consumption standard of living of your societal outcasts. If they can live on, say, 20% of the power draw that most of us do (with our computers, lights, electric hot water and heat pumps, appliances, and so forth), you would need something around 200 W per person average generating capacity. Multiply by 50,000 people, and allow for some reserve for peak draws, and you'd need between 10 and 20 megawatts capacity.
This is a pretty small hydro installation by 20th century standards -- one I used to see fairly regularly, The Dalles Dam (on the Columbia River that forms the border between Washington state and Oregon for a couple hundred miles) has a bit more than 2 gigawatts generation capacity (about ten times what your chasm city needs if they live in energy poverty, probably more than required to live like Americans do in the 2020s), while Hoover Dam (one of the largest hydro and water impoundment facilities in the Western Hemisphere) has barely more (a few tens of megawatts) and Grand Coulee dam (eastern Washington state), one of the biggest hydro generation facilities on Earth, produces about 6.8 gigawatts.
Cave streams exist with plenty of flow and head to produce the needed 10-20 megawatts -- though I doubt you could pull water out of a true aquifer rapidly enough to feed this need. You need to understand the distinction: an aquifer is water "flowing" by seepage through pores and cracks in deep rock or soil, while a cave stream (a true "underground river") is a free-flowing stream inside a naturally formed (or, rarely, artificial) cavern or tunnel; some form as streams above ground and flow into a cave, others form from drip water or springs inside a cave and flow out, and a few flow through natural tunnels -- going from above ground to underground and back to above ground.
Then again, maybe Roman technology (driving modern electrical generators) could have done this. There were a lot of water wheels driving various industries -- stone saws, wood sawing mills, grain mills, and textile related machinery -- from at least the Third Century CE. One of these, the Barbegal complex, had sixteen overshot wheels as well as the machines and shops they powered. Each of those wheels would need to produce about 1.25 megawatts -- or roughly 1500 horsepower -- to give the required generation capacity. One megawatt from water (ignoring the relatively large losses inherent in this kind of water wheel) would require a hundred cubic meters of water per second down a ten meter drop -- or the same product of flow and head. Even a fairly modest stream can do this if you have enough drop.
This is a Frame Challenge
The water source isn't the problem, it's channeling that source to a useful location.
Whether your source is an underground river or an aquifer, it doesn't matter. Frankly, an aquifer is a much better solution due to the increase in pressure from its enormous weight and the ability to draw substantially more water from the aquifer than from any underground river.
Some will disagree with this. But I ask you to consider the Ogallala Aquifer. With a maximum thickness of 800 feet the anticipated below ground pressure of the water at the aquifer's minimum level at that maximum thickness is 800 ÷ 2.31 = 346 psi. For ccomparison, the water pressure at the base of the Hoover Dam is only 312 psi. Add to that the reality that one could tunnel and extract hundreds of millions of gallons of water a day from a large aquifer like the Ogallala1 — but a river can only disgorge as much as flows.
What does this mean? The Hoover Dam supplies enough electricity for 1.3 million people. The Ogallala Aquifer, if you're tunneling below it, can supply that much just from one section of the aquifer. It can supply everything you need.
But where does all that water go?
That's your problem.
It's not the existence of water that generates electricity, but the flow of water. And that means the water must go somewhere. There are high altitude aquifers in the world (e.g., the Lhasa River Basin) that could be used as examples of an underground city drawing power from an aquifer or river and then disposing of it into the sea. As I said, a river already has an exit. But if you're using an aquifer, you're tunneling... somewhere.... So...
Use an aquifer, which could provide every joule of energy your underground city could possibly need, but you'll need to invent/create/explain/ignore where the water goes.
Use a river, which disposes of the water for you, but could limit the amount of energy you need for your city.
Conclusion, and to answer your question
YES! You can use either an underground river or an aquifer to power your city. Heck, all you really need to do is tunnel 500-1000 feet below the water source then dig a big old hole from your power plant up to the source. Instant power and a lot of it. You already have the ability to dig out the city, so digging out the vertical source shaft shouldn't be too hard.
But unless you want to ignore the issue (which you can, stories aren't required to explain everything and, frankly, not that many people would think to themselves, "Huh, I wonder what they're doing with all that water?"), you need to care about how you dispose of the water. That's a bigger problem than generating power from it.
1 Which is what we're already doing with the millions of wells we've dug to the Ogallala. In fact, we're draining it quite a bit faster than it can recharge. Getting water out of an aquifer isn't the problem if you dig enough wells. Getting the water back in.... that's the problem. But we'll ignore that today.
Aquifer has no usable potential energy. Underground river unlikely to have much of a flow but if you have it, water has the way out without filling up your big cave, so you can just drop any water on the surface above you city (e.g. usual river) into a hole, use the energy, let it flow to underground river. Amount of energy depends on how deep you are and how much water your underground river can carry outside.
50k is not a small city. You would need at the very least half an acre of land per person for agriculture, 25k acres, 10x10km, (6.3x6.3 miles). All this land needs rather intensive work and light, at the levels the Sun provides. It would require huge amount of energy. Technologically making a cave of such size, watering and lighting it would be a rather daunting task. If they pull this off, they likely have better tech than 95% of the people who has it easy on the surface.
They could use geothermal energy though. Or a "primitive" nuclear reactor.