Just to show you, your lower leg slightly rotates at the knee when the knee is flexed. Not going to go into a lot of detail because we don't tend to work this movement a lot. Semimembranosus, semitendinosus, and popliteus do internal rotation, and biceps femoris does external rotation.
Your lower leg does not rotate when it is fully extended, due to the "screw-home mechanism" that locks your femur on the tibia for stability.