Create a cylinder, subdivide it horizontally, assign it a vertex group at its top with the Gradient brush, create a ring object that you'll use to squeeze the hat, make sure that its face normals are facing inwards:
Give your cylinder a Cloth simulation, keep the default settings, except increase the Stiffness > Bending value up to 3 for example so that the folds are large enough, choose the vertex group as Pin Group, enable the Collisions > Self Collisions option, cut off the Field Weights > Gravity:
Give Collision physics to the ring, animate it scaling down so that it squeezes the hat. When you're glad, apply the Cloth modifier: