You could write a custom Dataset and concatenate multiple images to the desired shape.
ImageFolder will create samples using single image tensors and their corresponding target.
The more interesting part would be, how should the length be defined? Would you like to concatenate random images? If so, you could also increase the batch size and reshape the data such that the batch size will be split into a smaller batch size and the length dimension.
On the other hand, if the length dimension would have any specific “logic” such as sequential frames, I would recommend to stick to the custom Dataset approach and implement the loading logic in its __getitem__.