You could use a grouped convolution to and expand the kernel to the necessary shape:
x = torch.randn([1, 256, 3, 3, 3])
sobel = [[1, 2, 1], [0, 0, 0], [-1, -2, -1]]
depth = x.size()[1]
channels = x.size()[2]
sobel_kernel = torch.tensor(sobel, dtype=torch.float32).unsqueeze(0).expand(depth, 1, channels, 3, 3)
print(sobel_kernel.shape)
> torch.Size([256, 1, 3, 3, 3])
malignacy = F.conv3d(x, sobel_kernel, stride=1, padding=1, groups=x.size(1))
print(malignacy.shape)
> torch.Size([1, 256, 3, 3, 3])