Actually, to capture accurate colors, cameras must filter to XYZ or LMS weight curves. Any other linear combination of LMS filters with non-negative weights is acceptable, if they give you a better signal-to-noise ratio than LMS.
It is the RGB filters that are impossible to realize, because they have some negative weights along the curves (wavelength). If you try to realize some RGB color space directly on the sensor (i.e. with the Bayer filters) then you are guaranteed to make colorimetric errors. You can't make optical filters with negative gain.
Our eyes have the LMS filters (long-medium-short, roughly equivalent to red-green-blue). CIE XYZ are derived from that to be just non-negative, and so that the Luminance is defined by only Y. This is more convenient for color science. ACES RGB is another perfect conversion, convenient for digital film production.
Data in any other RGB color space (like sRGB = Rec.709, Adobe, DCI P3, UHD = Rec.2020) can be derived computationally from XYZ or ACES by a 3x3 matrix in linear-light. Such matrix will have up to 6 negative coefficients, so any out-of-gamut colors will produce some negative RGB values. These cannot be processed by the OECF (gamma function), so unless you store signed linear-light values they will have to be eliminated by gamut mapping (or just clipping to 0). The in-gamut colors can still be exact, because the math is exact.
The larger the color space is in relation to the color gamut of your scene (most of the world is not so wide-gamut) the less problem you have with gamut clipping. For scientific purposes XYZ cameras exist, they can reproduce exactly what the eyes see. Multi-spectral cameras with more than 3 primary colors can even see more than the human eyes could distinguish. They literally reveal the unseen.
In short: an XYZ sensor is an excellent idea. I suspect that in RAW mode this is what you should get. Conversion to a limited RGB color space is then done during the raw processing, and that is when you may lose some color gamut.
PS: do not confuse camera design with color display design. An XYZ display is impossible, a very wide gamut display needs many primaries (e.g. 2 greens). A wide gamut camera is trivially easy, but it outputs weak-color signals so there may be some noise issues.