If supported, try setting up the Apple TV remote volume control for use with the Sonos instead of with the TV.
Apple TV: Setting﹥Remotes and Devices﹥Volume Control﹥[Either sound system via IR, or Learn New Remote… (=copy signals from the third party device remote).]
If the Sonos has no IR receptor for remote signals, then this method may not be supported. The Apple TV remote wants to use IR (or else HDMI-CEC) for external audio systems like the Sonos.
Use the Apple TV remote to control the volume of your TV, sound bar, or receiver - Apple Support
Toslink optical connections do not carry volume control information.
Consider connecting via HDMI for a more automated approach, as the Sonos supports volume control through HDMI-CEC. I.e. then the remote sends the volume control signal to the Apple TV box, which relays that via HDMI-CEC to the audio system that does the actual volume control.
Control Sonos home theater with your TV remote (or streaming device remote) - Sonos Support
Use the HDMI (e)ARC port on the TV for the connection to the audio system. You may need to configure that port on the TV for high bandwidth eARC use, to unlock the ~37 Mbps capacity instead of ~1 Mbps for standard ARC.