Fabric care for a fiber blend should be based on the most delicate fiber in the mix, in this case the wool (percent of a fiber is also important, which is discussed below) . Wool fiber is a protein fiber like silk, and is weaker when wet, so be gentle with it, no tight squeezing, wringing, or agitation. (In contrast, cotton is stronger when wet so wringing out cotton items is OK.).
Use a large bowl or a plastic dish pan to hand-wash the hat. Make a cool solution of Woolite or delicate care liquid laundry detergent, use just a little detergent to a lot of water - a lot of suds means you have used too much. Push the hat up and down gently through the water. You can soak it if it is also really dirty, but in any case, be gentle.
Gently squeeze out the solution. Fill the bowl with cool water and repeat as above a few times, till there are no suds in the rinse water, 2-3 rinses should be fine.
Gently squeeze out the last rinse water. Loosely lay the hat on a clean folded towel and put another folded towel over it. Push gently on the top towel and hold and press gently for a few seconds to get most of the water out.
Depending on the percent of wool in the blend, you may or may not want to block it with steam. If the wool percent is high, say over 40 %, the steam blocking method described so well by @aparente001 is the way to go. Just be sure not to steam the ribbing when it’s stretched out, scrunch the ribbing together before steaming. The give and take - stretchiness- of the rib is what makes the hat fit around your face and head.
If the wool fiber content is low, say 20-40%, I would try blocking the hat by laying the washed and rinsed and gently squeezed and hand-pressed hat on a clean dry towel and scrunching the hat into the approximate size you want and patting it flat. Pay attention to the ribbing at the opening of the hat, push together the ribs a little all the way around.
If there is still a lot of water left in the hat at this point, you can repeat the two-towel sandwich and press and hold again.
The hat will dry faster if you use fresh dry towels through the drying process. Be sure to turn the hat over a few times as it dries. Do not hang the hat to dry, it will stretch.
If the percent of wool is very small, say 1-10% (which is true sometimes with expensive fibers like cashmere), and the rest is mostly acrylic, if it were me, I’d tumble dry the hat on low heat til it’s almost dry and then lay it on a towel. Acrylics are “self-blocking” in that they wash and dry beautifully and resume their original shape in the dryer.
Without knowing the exact composition of the blend, I.e., all the fibers in the blend and their percentages, it’s hard to be more specific than this.
Good luck! The friend who gave you the hat must be very pleased that you like it so much!