Keeping this in consideration, is it illegal to have yellow fog lights?
Fog lights should be yellow. But regardless of the colour, using them in fine weather conditions is illegal.
Also question is, why are some fog lights yellow?
Yellow light supposedly penetrates further because of its long wavelength, but it's still much smaller than fog particles. The scattering effects of fog are essentially independent of wavelength. Any color would do just as well. Red and blue are reserved for emergency vehicles, so yellow is what you get.
So despite what you may read online, yellow fog or driving lights can actually improve a night drive, especially in bad conditions. Not because they have a greater range or penetrate fog to a greater degree, but because yellow light is easier for our eyes to process, providing better definition.