The subject Samsung TV does not natively support Optical output thus making it initially a non-starter for the Sonos Ray or discontinued Sonos Playbar / Playbase. However, the converter shown in this Link may make connection to the Ray and/or Playbar / Playbase possible.
I cannot guarantee it will work but the cost ($20_USD) to try it and then return it if not successful is IMO minimal. If you try it please report back in this thread with your results.

