You might be able to do this by attempting to read the LED voltage using an ADC, but that may not tell you anything because LEDs are made using various chemistries. The only reliable way to do this would be to use a color sensor chip and aim it at the LED. You'll find that to be a much more expensive and complicated project.
Each wavelength / band gap - has a certain forward voltage drop, so that's what you'd be measuring... curious project I might have a play see what results i get...
wow, i've not seen one of them since 1988 lol, age 7 at the top of the stairs my dad gave me a 9v battery and an LED, thinking back the 9v battery was pretty dead (he got me to taste it, very very mild) but yeah i connected the LED both ways until it lit up glowed almost changing color (obviously, too much voltage) but as the battery went dead , the LED was this type!
digitalWrite(pin,HIGH);
use a 300 ohm resistor in series to keep the current down on these old things...