how to make a digital model of a twisted cylinder

I'm currenty doing a study project where I bend/twist a cylinder. see images below Anyone who have an idea how to construct this geometry. Its simply a cylinder where you grab two opposite sides and rotate one of the sides to the desired angle. In the images this is approximately 270 degrees