The LRx-x02 Datasheet says that for this series of stack light,
- Black is 0v, unless buzzer is present, then it's Grey (wire 9.)
- If buzzer is present, it is the Purple wire (6.)
- Yellow is +24v.
- Tying low (0v, 50mA max) to Red will illuminate the red lamp.
- Tying low (0v, current not specified) to Brown will make (all) lamps flash.
While relays could be used for this, you are correct, two relays would be needed. There is no such thing (that I've seen) of a three-position relay. The easiest solution would be to use two "open collector" transistors to pull these lines low:
simulate this circuit – Schematic created using CircuitLab
If the unit has a buzzer, then the purple wire (low) turns that on. A beefier transistor than the venerable 2N3904 would be required, as this draws more current than that transistor can supply under all conditions.
But realistically, only Q1 would be needed as you could turn on and off that GPIO to flash the lamp.
Also, for an industrial application, consider the Controllino instead of an Arduino.