The only way to do it with literally zero mathematical quality loss is to make a gigantic output file with a lossless codec. (e.g. utvideo, FFV1, or x264 in lossless mode (
A better solutions that would achieve the same thing is:
mux the subtitle file into the mkv, with mkvmerge. You set a flag so it either plays by default or doesn't. Then you'd have an output file with an untouched video stream, so there's no quality loss. Also, anyone who doesn't need the subtitles can turn them off. And you can move them around on playback, or use a different font or font size. e.g. You could move them down into the letterbox black bar that appears when playing a 16:9 video on a 16:10 screen, so they don't hide any of the movie.
If you really want to use the bad solution of drawing them on the video, you'd just going to have to accept the quality loss that you get from another generation of lossy encoding. Google an example for ffmpeg. It shouldn't take more than a minute to find a recipe. I'm not googling for you because I think it's a terrible idea to ever do this, unless you maybe have a hardware player that doesn't support any subtitle formats at all. (If it supports any subtitle format, converting your ASS subs to that format would be better.)
-c:v libx264 -preset slower -crf 20 as a starting point for your encode.
The ffmpeg full manual is: http://www.ffmpeg.org/ffmpeg-all.html But there's also a wiki with usage examples on their site.