I am not sure if it can be done via nn.Linear class.
But you can define your own custom module with nn.functionalal 2 module.
Somewhere on these lines:
def mylinear(nn.Module):
	def __init__(self, nin, nout):
		self.W = nn.Parameter(torch.zeros(nin, nout))
		self.B = nn.Parameter(torch.zeros(nout))

	def forward(self, x, condition):
		if condition:
			### No bias if condition true
			return nn.functional.linear(x, self.W, None)
		else:
			return nn.functional.linear(x, self.W, self.B)

I think it should do the job