This is a simple mod that monitors player buffs and if it detects you affected by Train buff, automatically sets Dialog sound channel to 0 volume. It automatically restores setting to your previous setting once Train buff is gone.
This mod also uses saved variables so if you logout in a train with Dialog muted, it should restore sound upon login when it detects this.