Sure, unless you have a choice for optical audio on the TV.
Your MacBook has an optical audio connector as part of the the line out connector, which just needs a normal extended toslink adapter for that, and whatever the optical connector would be on your TV.