Theoretically, one should be able gradually to reduce image B's dimensions until reasonable sharpness is detected (bringing it as close to image A as possible, although without actually comparing them at this point), and thus derive the image's "true" megapixel count: the size below which imagery is starting to lose its details.
You're starting out assuming that image B has no more detail. But even a completely flat region has detail - it's just that it's flat.
A lack of detail or change does not denote a lack of valid image data or resolution.
This value could easily be used to determine the usefulness of a photo - if I shoot it slightly out of focus, I can still print it in a smaller size, and no-one will notice.
This won't work as you think.
People, in my experience, don't care about detail in an image as much as they acre about emotional and/or informational content. What the image makes them feel or what the image tells them or both.
Unless an image is in exceptionally poor focus it's generally OK for some purpose. The only people, in my experience, who care about perfect focus are photographers and media editors (and the editors are getting less fussy these days).
I had a (technically) bad photo of a relative's daughter one time which had motion blur, camera shake, poor focus and lousy lighting.
It's been pinned to their photo wall for over a decade. No protest by me or offer to shoot it again has ever worked, BTW. They like that photo.
The value of an image is not defined by it's sharpness or resolved detail except in very particular commercial settings and even there it's not main the priority. No news editor will care how little detail there really is in e.g. that "exclusive" shot of some celebrity on holiday or, indeed, some victim of the latest outrage.
Or, it could help with assessing lens or sensor quality -
They have resolution charts for that. Those are well defined fixed patterns and suited to computer analysis. Have a look at DxOMark's website sometime.
Testing resolution against anything but a well defined and precisely known target is pointless.
if a 24 Mpix camera is unable to capture an image with more than "true" 8 Mpix, then something isn't right.
Just because a sensor doesn't capture more detail doesn't mean there is anything wrong apart from your expectations.
Detail captured depends on many factors. First the existence of detail. Then the shooting conditions, the aperture and optical characteristics of the lens. The lighting, the shutter speed, ISO and noise characteristics. Diffraction limitations.
The reality is that pixel counts have very less in practice to do with how much detail you really get when shooting that many other factors which limit what is possible or practical.