Why do you need to AirPlay from ATV to ray if it’s connected to the same TV?
And it depends on the TV. Some turn off the digital optical port when a CEC speaker is connected to the ARC port, some do not.
Either way, as the previous poster suggested, it would likely be a mess, with two sets of center, right and left channels.
And you shouldn’t be connecting at all via AirPlay 2, you should allow the TV to send the signal to the speaker whichever one you settle on. As far as I’m aware, once you choose AirPlay 2 on the Apple TV, it stops sending any sound out via ARC.
The others are correct regarding AirPlay. There’s no need when the ATV is connected via HDMI to your TV. You are essentially causing your own issues.
Furthermore Sonos isn’t designed to have two sound bars connected to one TV. Besides I haven’t yet seen a TV sound menu that will allow an HDMI and Optical sound out-put simultaneously. Then again…I haven’t tested every TV in the market 
If by using the Ray as a secondary speaker the answer is yes if you group the Ray to the Beam. However, there will be 75ms delay for TV audio to the Ray causing an echo effect if in the same room. For streamed music there will be no delay.