They make ADCs that convert Analog audio to toslink.
Here's just the first one I found (probably works fine? It's a simple device)
https://www.amazon.com/Musou-Digital-Optical-Toslink-Converter/dp/B07L9KM67Y
https://www.amazon.com/Musou-Digital-Optical-Toslink-Converter/dp/B07L9KM67Y/ or equivalent