I assume the composition of the S&P 500 is a matter of public record. As is the stock price of public companies. Seems pretty straightforward. I don't know if the exact weighting formula is public but you could at least approximate.
You're essentially looking at replicating the DJIA for companies that may not be on the Dow Jones. Part of me assumes this has been done but interesting.