I have been looking at buying/building a 500 for years now(and I will when I run across the right deal).
Frame up from junk, or complete in decent shape.
The engine(and complete quad) prices I've seen vary greatly.
If you're going to pay more than a few hundred dollars for an engine, I would want receipts for internal parts/work done, or know/trust the seller.
They always seem to have "low hours" and have been "barely ridden", for whatever that's worth.
Parts for the 500 engine are expensive in comparison to most other 2-strokes.
How a 2-stoke engine is broken in is also important for it's lifespan. Correct break-in almost always means longer engine life. Unless the engine was built and broken in by someone knowledgable, chances are it was thrown together, cranked, an ran. If it was jetted too lean and ran that way, that also shortens it's life.
87 models need the head studs fixed. The "ears"(bolt mount holes for the cylinder)need to be strengthend. As well as several other quirks the 500's had.
I make no claims to know alot abou the 500's, but have been wrenching and riding for 26 years, 2 and 4 strokes, atv's and sportbikes(and unfortunately cars too, lol).
The 500 seems to be one of the more expensive 2-strokes I've seen for parts. If you build it, torque everything to spec, use quality parts, set the squish correctly, make sure ring end gap is correct, make sure the carburetor is jetted correctly for any mods and your elevation, break it in right, ect, ect. Do it by the book, and talk to engine builders if you have any questions. There are alot of simple things to do(like the above mentioned), and many people don't do those or any. It makes a difference.
Otherwise it'll be even more expensive.
When buying a used engine or whole atv, doing a compression check and leakdown test will give you a good idea of the engine's condition. Do that, or have it done whenever possible.
I'm sorry, but I honestly don't think there's a good answer to the question; "How much will it cost?".
The best thing to do(no matter what you're working on) is to start with a budget, see what you can find to buy, then guesstimate what parts you're fairly certain you will need. I promise you there will always be something else to add to the list.
But, there is alot of great info and some very knowledgable people here.
Good luck.