I recently had my rear wheel replaced because the old one was bent. Everything about the new wheel was correct except that the shopkeeper ordered a 36 hole rim instead of 32 one. Due to this he told me he had to fit a new hub as well. The problem is my bicycle came with high quality hubs and the one he replaced it with cost ~$3. My rear wheel is wobbling now and I suspect it's the generic hub. Buying a new hub will cost me twice the price of the wheel. Can I just reuse the old one with the new wheel
Theoretically? Yes. Practically? No.
the shopkeeper ordered a 36 hole rim instead of 32 one.
In most of the world this is his problem. You ordered new rim that will it your hub from him, so that's what you should get. Go to him, tell him you want what you ordered, that is a rim on your hub, or you want your money back and go to another repair shop to make your wheel. If he opposes, then it is a question for sister site, Law Stack Exchange. But if you are in the European Union shopkeeper is on a losing position. I believe that's the case for most of the western world.
The problem is my bicycle came with high quality hubs and the one he replaced it with cost ~$3.
Been there, done that. I have purchased several new bicycles, and almost invariably the manufacturer has decided to save money by using non-Brand hubs. Usually those are some $3 Taiwanese ones. A hub is the second most difficult component to change in a bicycle, the frame being the most difficult component to change. It does not make sense to save money on hubs.
Buying a new hub will cost me twice the price of the wheel.
I don't understand how this can be the case. I just built a 36-spoke wheel and the hub (a brand named one) cost 67.73 EUR. The only reason it cost so much is that this is a thru-axle hub and those are usually more expensive than quick release ones. The rim cost 59.89 EUR, the spokes cost 17.70 EUR and the nipples cost 3.56 EUR. The rim tape cost 2.35 EUR, the tire cost 39.90 EUR, the brake disc cost 23.90 EUR, the tube cost 6.24 EUR and the cassette cost 26 EUR.
So the wheel cost is 118.88 EUR without rim tape, tire, brake disc, tube and cassette. With these, it cost 217.27 EUR. I built it myself so I didn't calculate price for my labor. I built it in little over 5 hours -- a professional wheelbuilder could surely do a sufficient job in one hour.
Of these figures, the hub is a very small amount.
Of course, it could be the case that there is some non-brand manufacturer of hubs selling poor products at exuberant costs. You need not buy such products. Stick with Brand hubs.
Can I just reuse the old one with the new wheel
The hole counts must match. You need to order a 32-hole rim or a 36-hole hub. I recommend the latter. 36-spoke wheels are noticeably stronger than 32-hole ones. Actually, originally nearly all quality bicycles had 36-hole wheels (source), with the exception of some special purpose racing bicycles that need not last more than one race. Then some clever marketeer decided to sell 32-spoke wheels in regular bicycles, selling these low spoke count wheels as "upgrade!" and cutting costs at the same time (less spokes = less wheelbuilding time). Those 32-spoke wheels are not as durable as 36-spoke wheels. Clever idea -- sell a cheaper product at greater price for the customer. You need not buy such wheels, obviously. Select a durable 36-spoke wheel instead.