I was wondering if people could build a city of sorts underground, with artificially-lit greenhouses, electricity + water, ventilation, etc. (essentially, as similar to an above-ground city as possible, with all the necessary adjustments), and manage to make it sustainable for 500+ years? And how might this impact technology?
They have a few setups like that. Like the great salt mines in ancient times, and some other hidden and underground cities. The idea was to get your food elsewhere, and to go above ground, though. But they did build a lot of churches underground due to the large amount of time spent there. http://www.dailymail.co.uk/sciencetech/article-2833574/Not-exactly-winter-sun-Feat-engineering-lets-holiday-underground-medieval-salt-mines-boasts-fairground-boating-lake-health-benefits.html
More recently, we do have some underground facilities like those in the Ozarks: https://vimeo.com/54786793
500 years is hard to say... I don't think any canned foods last that long, but with a nuclear reactor you might be able to power the underground lamps for your vegetables. And livestock are easy to keep underground if properly fed. The UV lamps will also give you your needed vitamin D.
Now, making the nuclear reactor last that long is a bit tricky. You'll need a lot of skilled labour and resources (as you already will) to repair, and potentially replace it. Stockpiling enough uranium for 500 years should be possible to fuel the reactor. If you don't have a lot of uranium, you might need to refine the waste U238 uranium into plutonium, then make use of a plutonium reactor. Those are... a little iffy and terrifying, but should be possible.
You'll also need excellent air-conditioning. Living underground for prolonged periods is not good for your health. Your underground people may suffer health issues even with excellent facilities, if they spend all their time underground. NASA and submarine crews have been finding problems with managing this, despite a lot of research put into it, and that's without the issues of all the dirt, dust, and possibly gasses that can be an issue digging underground. Submarine crews need to have shore leave and take trips to the surface so that they can manage. In truth, we're not sure how exactly things will work out, if you stay too long underground and in a controlled/simulated environment.
Managing water and sewage will also be an issue in an underground city. You need a lot of water, and stuff like rain if it can soak into your city can add up to a lot of water you need to get out of the way. Alternatively, if you don't have a supply of drinkable water constantly, your city will be in danger. Cleaning sewage into usable water is likely to be a thing.
There have been attempts to build a fully enclosed ecology, like the Biosphere 2 experiment. Building something like that in an underground location would require artificial light, which can be generated with enough power. Power could be e.g. geothermal.
If the underground city can tap aquifers and take in filtered air, it will have it easier than the Biosphere experiment. On the other hand, running for multiple generations will have it much, much harder. What if parts wear out? What if people die? (See the 4th paragraph of this.)
The underground city would have to run industry inside, not just farming and scientific experiments. At least one science fiction novel wrote the best scale for a replica ecosystem is 1:1.
There is a book that I believe is on this subject. I haven't purchased it yet, but intend to. https://www.amazon.com/Feeding-Everyone-Matter-What-Catastrophe/dp/0128044470/ref=sr_1_1?ie=UTF8&qid=1478230211&sr=8-1&keywords=feeding+everyone+no+matter+what