UPDATE: I tried selecting the erase whole drive option (instead of manual partitioning) and encrypt from there, and that seems to be working. I tried both Kubuntu 24.04 and Lubuntu 24.04 in VirtualBox, and they both seem to be working as expected. So the problem might be with manual partitioning only, which worked back in 22.04 but not in 24.04.
UPDATE: I tried selecting the erase whole drive option (instead of manual partitioning) and encrypt from there, and that seems to be working. I tried both Kubuntu 24.04 and Lubuntu 24.04 in VirtualBox, and they both seem to be working as expected. So the problem might be with manual partitioning only, which worked back in 22.04 but not in 24.04.