Supermode-based second harmonic generation in a nonlinear interferometer