I think deriving another class from your original UNet and changing the forward method accordingly is a valid approach.
If you know about this use case before writing the initial model, you could also separate the encoder and decoder in submodules and use a passed flag in the forward method to use different branches.