I actually have a similar problem right now.
Each object in my game can only have one unique colour and black. The object material is a standard lit material that takes a texture and converts it into a 1 bit black and white image before applying a colour to the white parts.
I also have a bastardised cel shader that bypasses shading and instead either prints the DiffuseColor scene texture or black. There’s an outline post process shader too but that can be ignored for now.
In the cel-shaded shadows, I’d like to have the inverse happen - the black would be the colour and the colour would be the black. Ideally I’d have this part sent to its own texture, like a second material that I can access when I want, but I’m not sure that’s possible. Even in the forward renderer it was janky, and post processing is a nightmare with the forward renderer.
This is the gist of the cel-shader - at the moment, I’m desaturating it to black and white to try and get something out of it but for some reason that doesn’t work either. Here is the regular desaturated diffuse, the inverted one, and the combined result with skybox (which leaves the shadows completely black because the normal diffuse overlays on top of the inverted one). I’d then recolour them using the custom stencil because I’m fortunate enough to be only using one colour per object.
Like you, I would like to do this within the material because that gives me control over the threshold for colour, so there’d be more black in the shadow texture than just the inverse of the light texture.
I also tried passing the secondary texture through other nodes on the material to no avail, even split into R/G/B then reassembled post process, but the way the different buffers work make that data impossible to preserve.