In level 36 if you jump from the gold block and chuck the hat when the guard is at the edge of the rail area, once will stop them moving and another time will put the hat on their head. Looking at other comments, this is not how it was intended to be done but this bug isn't that big a deal.
In level 36, I was able to jump from the gold block and throw my hat onto the guard. Whilst this may be how it is meant to be done, on one go of the level, I didn't catch the guard fully, and they stopped as if wearing the hat but not actually wearing it.