A Google Books search reveals four populations in which the hat-on-bed prohibition is specifically cited multiple times: African Americans and Jamaicans; Italians; actors and other theater people; and cowboys. Here are some mentions involving each population.
African Americans and Jamaicans
From "Folklore of the Negroes of Jamaica," in Folk-Lore: A Quarterly Review (December 1904) [from papers written by students at Mico College, Jamaica, in 1896]:
Do not put your hat on a bed, for misfortune will surely overtake you.
If a young man turns down his hat on a table he never gets married.
If a young man puts his hat on a bed it prevents him from getting married.
From Blanche King, Under Your Feet: The Story of the American Mound Builders (1939):
The negroes in the South have many superstitions. Never, never, step over a broom; either pick it up or walk around it. (Walking around suited most of them better.) Never put a hat or umbrella on the bed and, heavens ! never come in one door and go out another. And as for knocking on one's door, our colored house man said, "Oh! no, no, Ma'am, I knows I nevah would knock on my own do'."
From Hope Landrine & Elizabeth Klonoff, African American Acculturation: Deconstructing Race and Reviving Culture (1996) [combined snippets]:
Superstitions (31 items). These items were meant to assess old superstitious beliefs that many African Americans were taught by their grandparents and whose historical origins appear to be ancient (former) cultural practices. Items included,
You should never put a hat on a bed.
I eat Black-eyed pas on New Year's Eve (for luck).
The first item, for example, appears to stem from the ancient practice of voodoo among the slaves and freed slaves, in which a a hat was placed upon a person's bed to warn him that maintaining his present course of action would be met by a curse, hex, or other negative reaction.
Italians and Italian Americans
From Differentia, issues 5–7 (1991) [snippet]:
My father once screamed like hell when I, too young even to know what a superstition was, put a fedora on the bed. ”Never put a hat on the bed,” he said, breathlessly, after leaping across me to grab the offending object. Now, isn't that Italian?
From Hugh Shankland, Simple Guide to Italy: Customs & Etiquette (2001) [combined snippets]:
Many commonly held superstitions will already be familiar, others less so: a black cat crossing your path is a most sinister omen, never sleep in a bed with its foot facing the door, never put a hat on a bed, or break a mirror, avoid spilling salt or pouring wine 'backwards' with your hand held under the bottle, and do not leave a loaf or breadroll upside down or the devil will dance on it.
Actors and other theater people
From Bailley Lane, "The Facts That Were Suppressed," in Green Book Magazine (June 1913):
"Marjie and I were out all this season in the "Stubborn Cinderella" eastern company, and say, we like to died. It as a peach of a show—good 'laughs.' good music, and some awful pretty scenes, but we had a bum comedian and a dozen stage managers, and then times were awful. Just seemed there was something on that troupe from the beginning. One night in Boston during rehearsals Marjie threw her hat on my bed, and I might have known then things were going to turn out bad. A hat on a bed? Oh, heavens, I should say so!"
From Leonard Ashley, The Wonderful World of Superstition, Prophecy, and Luck (1984) [combined snippets], referring to superstitions once common among actors and other entertainers (confirmed by Charles Dillon, Superstitions and Folk Remedies ):
Never whistle in a dressing room.
Never put a hat on a bed or shoes on a table.
Never quote from Macbeth or Hamlet in conversation or repeat the last line of play dialogue at rehearsal.
Never use real flowers on stage or accept real flowers over the footlights.
Never have lilies or peacock feathers around — perhaps a stage version of antipathy to the Evil Eye.
Never have yellow in a set or green in a costume if it is at all avoidable.
From Margie Schultz, Irene Dunne: A Bio-bibliography (1991) [combined snippets], describing a 1936 interview of Dunne in New York, where she was on hand for the premiere of the movie Show Boat:
Irene discussed her dislike of radio work, ironic since she later performed extensively in that medium. Although she had not performed on stage for six years, she believed in a few superstitions that were akin to theatre folk: never fix up too nicely or some other actress may take your part, never put a hat on the bed, never whistle backstage, ...
From "Grace of Monaco," in People Magazine (September 12, 1983):
Like George Kelly, the playwright uncle she adored, Grace amused her kids with her superstitious quirks. For instance, no one could put a hat on the bed because it might bring bad luck. On special occasions she would put a penny inside her shoe. She would extract herbal remedies for ailments from flowers. Grace saw the humor of it all. "She could be silly and giggly," says an intimate.
From Wayne Wooden & Gavin Ehringer, Rodeo in America: Wranglers, Roughstock & Paydirt (1996) [combined snippets]:
Like athletes in other sports, many rodeo cowboys are superstitious. For good luck, a cowboy should not place his hat on a bed, eat peanuts, wear yellow, or quit roping practice on a miss. "It's just a mind game," scoffs saddle bronc world champion Billy Etbauer. Still, he heeds the superstition about the hat on the bed. "I used to get my butt chewed out for putting my hat on the bed," he says, though he can't explain why it is associated with bad luck. "I just put it anywhere but the bed."
Dick Hyson, The Calling: A Novel (1998) [combined snippets]:
"Don't ever lay your hat on a bed!" R.C. looked at me kind of with wonder.
"If there's anything that's bad luck to a cowboy, it's that. Now I don't particularly care what might happen to you, and what bad luck it might bring you, but the problem is, I might be with you when it happens. That bad luck might get both of us. So keep your hat off the bed! Understand?"
From James Sasse, Luck!: How to Get It and How to Keep It! (1998) [combined snippets]:
Apparently, if you're a rodeo competitor you should:
never compete with coins in your pocket
always shave before you compete
never leave your hat on a bed — if you do, you could be injured or killed.
Other populations and interpretations
In addition, there are some general references to the superstition as being "American" and some instances where other specific populations are identified with it.
From American Notes & Queries, volume 4 (1944) [combined snippets]:
A Hat on a Bed. I have been told that the belief that placing one's hat on a bed brings bad luck originated with gangsters of New York (or, possibly, some other large city) back in the twenties. When rival gangs met in a hotel room, according to this explanation, each man permitted himself to be searched — but the first to occupy the room hid their guns under their hats on the beds. I should like to know whether this is an acceptable interpretation, and I would also welcome other ideas on the subject. —Haseltine Russell
From Harry Hyatt, Folklore from Adams County, Illinois (1935):
To lay or throw a hat on the bed will cause you bad luck.
It is unfortunate to lay a hat on the bed unless you place the crown down against the counterpane.
If a hat is laid crown downwards on a bed, the owner of the hat will meet with bad luck.
Laying a hat on a bed will bring bad luck to the person who sleeps in the bed.
From "No Matter What Game, Players Have Charms and Tabus," in The Literary Digest (1937) [combined snippets]:
Boxers hate to see a hat on a bed. In 1932, after Max Schmeling lost his heavyweight title to Jack Sharkey, a friend came into his dressingroom and carelessly tossed his hat on the bed. When the fighter and his handlers learned he had done this constantly at training camp, they realized why Schmeling had lost.
From Mary Pat Kelly, Special Intentions (1997) [quoted language not shown in snippet], a novel about an Irish American Catholic postulant from Chicago:
I swung the black suitcase up on the bed. She shook her head and pointed to the white speckled chair. "Never anything on the bed. Including you. No sitting." "OK." Why? I wondered. My mother thought it was bad luck to put a hat on the bed.
From Richard Young & Judy Young, Ozark Tall Tales (1989) [combined snippets]:
Throwing the hat on the bed is a sign of intimacy. Ozarkers are divided on the outcome of placing a hat on a bed; in the deep woods, it's a sure bringer of bad luck. In some other places the bed, usually in the same single room as most of the other furniture, is the rightful place for a large group of guests to lay their hats and coats. For a single man to lay his hat on a sweetheart's bed has sexual overtones.
From Cynthia MacGregor, Family Customs and Traditions (1995) [combined snippets]:
Last of all, she [the writer's grandmother] believed you should never put a hat on a bed. She realized the original rationale behind that was to avoid spreading head lice, but she was convinced it would bring bad luck. She promoted her superstitions through the family all her life. —Jomil Mulvey, San Diego, California
From "The Sexual Symbolism of Hats," in American Imago, volumes 6–7 (1966) [combined snippets]:
Further superstitions with regard to hats are referred to both by Mr. [Vance] Randolph and Miss [Claudin] de Lys in their books. The former says (14) ; "It is always bad luck to place a hat or a shoe or a rifle on a bed." Miss de Lys corroborates this (15), and explains that the belief with regard to hats stems from the Orient and the Near East, where a turban or headgear of any kind is never supposed to be placed where another person's head may rest. She quotes the further belief (16) that placing a hat on a bed will result in a quarrel between the owner of the hat and the owner of the bed. Now if we follow our interpretation of the hat as a symbol of the male genital, it necessarily follows, in my opinion, that the bed is to be interpreted as a symbol for the vagina. But why the bad luck? Here our psychoanalytic experience comes to our aid, for we find that those neurotics who are obsessed ...
The likeliest source—if there is a single one—for the superstition is either the African diaspora (the Jamaican instance cited above from 1896 is the earliest in the Google Books search results) or the world of theater/acting/entertaining (which yields matches from as early as 1913). But the cowboy and Italian instances seem to have little overlap with those two, leading to the possibility that multiple cultures and subcultures have adopted the same superstition by chance.
As for the underlying reason for the taboo, numerous explanations are suggested in the search results, but none of them is particularly persuasive, and none seems to have gained much scholarly support.