Only virtually though, because physically your height won't change.
(In alphabetical order)
Truth is that hairdo isn’t so much essential about this thing, because when it comes to height, people tend to look at someone’s shoulders mostly and not someone’s scalp. But it might contribute by being recognizable in public or not. For example if a 170 cm man has a massive Mohawk that gives him an extra 15cm boost, he is going to be more recognizable in public than someone with the same height, but with short hair.
It depends on the hat, and how you wear it as well.
If you want to appear shorter: Don’t wear any.
If you want to appear taller: Wear those fedora hats, and place them a little bit above your ears.
If you want to appear shorter: Try to slouch. But NOT so much visibly. Just drop your weight down to your legs.
If you want to appear taller: Stand as straight as possible.
Although it’s visible, it can give you the feeling being taller/shorter than your friend/partner or whatever, depending on where do you walk on.
If you want to appear shorter: Walk on the road.
If you want to appear taller: Walk on the sidewalk.
Actually, this is the most essential thing when it comes to manipulating your height.
If you want to appear shorter: Wear flats. Or even better take out the inner soles as well, in order to make them as flat to the point you feel the ground when you walk.
If you want to appear taller: Wear high heels if you are a woman, or those elevator boots that people like Bono and Robert Downey Jr. wear in order to fake their height, if you are a man.
This is mostly for comparing yourself with another person, and if you know how tall is the other person also.
If you want to appear shorter: Sit if you know the other person is shorter, or stand next to him/her if you know he/she is taller than you.
If you want to appear taller: Just stand next to him/her as long as you know you are the taller one.
Depending whether the stripes are horizontal or vertical they can make some fake effect actually.
If you want to appear shorter: Wear horizontal stripes
If you want to appear taller: Wear vertical stripes