Compressing multireference character of wave functions via fermionic mode optimization