I think the easiest way would be to create a custom module and pass the output_size to it, if it’s static and should be used in an nn.Sequential container as seen here:
class MyConvTranspose2d(nn.Module):
    def __init__(self, conv, output_size):
        super(MyConvTranspose2d, self).__init__()
        self.output_size = output_size
        self.conv = conv
        
    def forward(self, x):
        x = self.conv(x, output_size=self.output_size)
        return x


conv = nn.ConvTranspose2d(1, 1, 2, 2)
x = torch.randn(1, 1, 24, 24)
out = conv(x)
print(out.shape)
> torch.Size([1, 1, 48, 48])

out = conv(x, output_size=(49, 49))
print(out.shape)
> torch.Size([1, 1, 49, 49])

my_conv = MyConvTranspose2d(conv, output_size=(49, 49))
out = my_conv(x)
print(out.shape)
> torch.Size([1, 1, 49, 49])

model = nn.Sequential(MyConvTranspose2d(conv, output_size=(49, 49)))
out = model(x)
print(out.shape)
> torch.Size([1, 1, 49, 49])

If you need to set output_size dynamically, I would recommend to write a custom model and not use nn.Sequential.