Such a sensor (used to) exist, Foveon X3. It is very interesting as it also uses the differential absorption of different wavelengths of light at different depths in silicon to distinguish colours: https://en.m.wikipedia.org/wiki/Foveon_X3_sensor
It had various advantages, and some disadvantages related to distinguishing colours, but ultimately wasn’t very successful in the market despite getting shipped in some DSLRs, possibly due to the marketing challenges (Bayer array sensor manufacturers count each R/G/B sub pixel as part of their “megapixel” count, so the Foveon sensor appeared low resolution by that metric).