Just to steal/compile what others have said and add my own gibberish on top of it:
Any WAV or FLAC file containing a DTS-encoded signal is, by design, going to look like normal stereo to anything but a DTS decoder.
Consequently, the first thing you'll need to do is decode the original "two channel" (as most software will see it) lossy encoded DTS file to a six-channel WAV file. The actual contents of that file will still be lossy, but there's no way around that. I don't think any DD/AC-3 encoder is going to be designed to first check if a WAV file actually contains DTS-encoded material, so if you simply try to encode the extracted DTS as is you'll just wind up with noise. I don't know if Linux tools like ffmpeg can do the conversion, but I'd probably start there.
Then you will probably need to convert that WAV file, which will be 44.1kHz if you ripped it from CD, to 48kHz. I have heard rumors that some hardware will play back DD at 44.1 kHz, but the only time I ever tried I just got silence.
That 48kHz WAV file can then be encoded to Dolby Digital.
Be aware that you will be starting with a file that has already undergone significant lossy compression, then you'll be manipulating the sample rate, then converting the results of that to an even lossier format. I'm not insisting that you'll be able to hear (or be bothered by) the chained processing against an already lossy source, but it's certainly possible.
Also, I don't know if there's a real risk of this or not, but my gut tells me that there's a possibility that AC-3 and DTS will handle "frames" differently, so you may find that if you process everything as individual tracks you'll hear disruptions at any break where the two tracks are supposed to flow seamlessly. Hopefully I'm wrong, but if not you may need to process the entire album as a single file and split it back out later.
The good news is that you're OK with Linux, so you can probably figure out how to script the whole thing fairly easily.