The simplest approach I could think of is
if bias:
    self.register_parameter("bias", Parameter(torch.Tensor(out_channels)))
    self.register_buffer("mask_bias", torch.ones(out_channels))
else:
    self.register_buffer("bias", torch.zeros(out_channels))
    self.register_buffer("mask_bias", torch.zeros(out_channels))

as a zero bias should be equivalent to no bias at all