I found you a solution of sorts. If you tune the channel from the guide once it turns on cc. If you tune it a second time it turns it off:
#/bin/bash
IPADD=192.168.1.171
#STARZ
if [ $1 = "842" ];then
sh /opt/opendct/stopbmitune0.sh
adb -s $IPADD shell "am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/-Y5vv28gO_I?onboard=1; sleep 9"
adb -s $IPADD shell " sleep 8; input keyevent 19; input keyevent 20; sleep 1; input keyevent 21 21 21 21 21 21; sleep 1; input keyevent 22 22; sleep 1; input keyevent 23"
fi
The first thing is to stop YTT if it is playing. Next it tunes the channel of choice. Finally after waiting for the channel to tune it turns on cc (or turns off if it is on).
If you go back to guide or stop and then tune the same channel it should tune and do the opposite with cc (turn it off if it is on or on if it is off).
You might have to tweak the timing based on your device. What I have here works on a NVIDIA shield.