You can access the material of the lamp object in the Unity-API.
public GameObject lampObject;
public bool isGreen;
public Color greenColor, redColor;
private void Update()
{
lampObject.material.color = isGreen ? greenColor : redColor;
}
This will set the material color of the lamp to a specified value you can edit in the inspector. It is also possible to lerp to the target color with Color.Lerp
.
var targetColor = isGreen ? greenColor : redColor;
lampObject.material.color = Color.Lerp(lampObject.material.color, targetColor, 0.1f);
The 0.1f will control how fast the color will blend to the target color.
Other possible ways would be -as you said- changing the texture of the lamp object texture by accessing lampObject.material.mainTexture
but I dont see any reasons to change the whole texture just for a traffic lamp color.