Though the fedora is not randomly generated in-game, the Archeologist role always starts out with one.
Due to its lack of special ability, AC benefits, or even sell value, the fedora is often ditched at the beginning of the game for the first helm the player finds.
The fedora is a felt hat with a wide brim (about 2.5 inches or 6.4 cm) and a distinctive lengthwise crease in the crown; the style goes back as far as the 1880s. The name is derived from the 1882 Victorien Sardou play Fedora, in which actress Sarah Bernhardt (whom the play was written for) wore one while playing the titular "Princess Fedora"; the term itself would see regular use as the early 1890s. Fedoras were especially popular from the 1920s to the early 1950s, and fell out of widespread fashion after the mid-1950s - they are still occasionally seen worn as accessories in the modern day.
The Indiana Jones franchise is first set in 1936, and is significantly inspired by Secret of the Incas and its main character, Harry Steele; the fedora's inclusion in NetHack is part of the Archeologist role's homage to the series.
Variants tend to play up the Indiana Jones homage more and/or make the fedora closer to a luck item.
Some hats can only be worn if you're willing to be jaunty, to set
them at an angle and to walk beneath them with a spring in your
stride as if you're only a step away from dancing. They demand a
lot of you.
[Anansi Boys, by Neil Gaiman]