One easy way to wear a bandana under a hat is to fold and tie it into a kerchief, and then place the hat on top. To fold a kerchief, first lay the bandana on a flat surface and smooth it out.
Fold the bandana across two diagonals to form a triangle, and again smooth it out. Raise the bandana from the two ends of the crease, and place the creased edge across the back of the neck. Tie the ends into a knot, leaving ample space between the neck and the knot. Turn the bandana so that the peak appears in front. Pull the peak up and over the head so that the crease goes across the forehead. Then place the hat on top of the bandana.