How to make ffmpeg flush the subtitles in real time while transcoding?
When ffmpeg will flush to output depends on the protocol. For file protocol, atleast 256 kiB data must be waiting, unless it's end of output. So, for text formats, there will be only one payload write.

You can workaround by forcing ffmpeg to flush a stream after each packet.

 ffmpeg -nostdin -i - -map 0:2 -c:0 webvtt -flush_packets 1 -f webvtt first.vtt \
-map 0:3 -c:0 webvtt -flush_packets 1 -f webvtt second.vtt \
-map 0:0 -c:0 copy -map 0:1 -c:1 aac \
-use_timeline 1 -min_seg_duration 1000000 \
-use_template 1 -init_seg_name $RepresentationID$-0.mp4s \
-media_seg_name $RepresentationID$-$Number$.mp4s \
-adaptation_sets "id=mkv/0,streams=0 id=mkv/1,streams=1" \
-f dash -dash 1 out.mpd