Mispricing can only be measured relative to some asset pricing model
Fama (1970) famously defined an efficient market as, "a market in which prices always 'fully reflect' all available information."
A perhaps less widely understood point of Fama is that any test of market efficiency is a joint test of: (1) market efficiency and (2) an asset pricing model! To say prices are wrong (i.e. inefficient) given available information you must say something about what prices should be given available information.
A core problem with what you're proposing
To have some time-varying measure of S&P 500 inefficiency, you'll have to say, at various points in time, something about what the price or expected returns of the S&P 500 instead should be!
It'll be a tough row to hoe though to justify statements of the form, "the price of the S&P 500 is 2% too high" or "the expected return of the S&P 500 is 2% too low." Can you convincingly argue you know when the price of the S&P 500 is correct and when it's wrong?
I'm not arguing this is impossible: you have periods such as the 90s tech boom where such inefficiency is plausible. It's a bold claim though, and you're inviting the snarky question of, "so where's your successful hedge fund?"
Other comments
The CAPM does not work and is not a reasonable asset pricing model to use in academic finance. Empirically, average returns are if anything declining in market beta rather than rising as predicted by the CAPM.
You correctly recognize that under various factor and multi-factor models, the S&P 500 will most likely be priced correctly as it'll have a beta of near 1 with respect to the CRSP value weight index (which is the typical proxy for the market portfolio in factor models), a near zero loading on other factors, and no significant alpha leftover.
Is there any chance you instead want to measure liquidity? Liquidity is a somewhat nebulous concept that while being difficult to measure, is perhaps more measurable than inefficiency.