Scientists and government officials fighting the coronavirus epidemic say they have a problem: Carefree youths.

As authorities moved to restrict social gatherings last week, bars and restaurants from New York to Berlin filled up with revelers, illegal “lockdown parties” popped up in France and Belgium, and campuses in the U.S. lit up for end-of-the-world dorm parties.

Get news and analysis on politics, policy, national security and more, delivered right to your inbox

So far, most young Covid-19 patients have experienced mild or no symptoms from the virus, while more severe cases are concentrated among those aged 50 and over. Data released last week by the National Health Institute in Italy, currently the world’s worst-hit country, shows mortality rates starting at 0% for patients aged 0 to 29 and edging up to peak at 19% for those over 90.

Yet scientists say tests have shown children and young adults are no less likely than older people to get infected and transmit the virus. Epidemiologists are growing concerned that the millennial pushback against social-distancing measures—and an emerging generational divide about how the disease is perceived—could undo all efforts to slow the spread of the virus and put vulnerable people at high risk.

President Trump on Monday stressed that young people can spread the virus even if they only have mild symptoms and recommended that Americans avoid restaurants and gatherings of more than 10 people. French President Emmanuel Macron went further, announcing a nationwide lockdown and punishment for those who violate the rules.

So far, the young don’t seem to be listening.

After social media became filled with reports of packed bars and restaurants in New York, 30-year-old Rep. Alexandria Ocasio-Cortez (D., N.Y.) tweeted to her millions of followers on Saturday.

“To everyone in NYC but ESPECIALLY healthy people & people under 40, (bc from what I’m observing that’s who needs to hear this again), PLEASE stop crowding bars, restaurants, and public spaces right now. Eat your meals at home.”

After Princeton University said last week it would close on March 19 and send most of its students home, the campus saw an explosion in gatherings and parties, according to students and staff.

“People were not ready to give up their lifestyle without one last hurrah,” said Ben Weissenbach, a Princeton undergraduate English major who was critical of some of the partying. “At a really privileged place like Princeton, we don’t tend to even consider the possibility that our bubble could be popped.”

Slideshow by photo services

In an email to all students on Friday, the university announced stricter measures and penalties for offenders, saying “we are disheartened to see that so many students are failing to heed these protective measures and engaging in disruptive behavior.”

In a display of juvenile gallows humor, the hashtag #BoomerRemover, a nickname for the novel coronavirus, briefly trended on Twitter last weekend.

Across Europe, where social life is shutting down faster than in the U.S., a divide is spreading between the young, many of whom say they don’t fear the virus, and their elders, including politicians and scientists, whose alarm about the illness is growing by the day.

In Berlin, a European clubbing hot spot, authorities ordered the closure of all bars and clubs on Saturday. Yet many establishments ignored the decree, forcing police to forcibly shut down some 63 establishments across the city.

That night, the Ernst basement bar in the trendy district of Kreuzberg was packed with patrons enjoying loud electronica. “Beware: Coronavirus” was sprayed on a bench near the entrance.

Inside the stylish Wagemut cocktail bar, a young woman pretended to sneeze in someone’s face, unleashing thunderous laughter.

On Sunday, Berlin health officials said 42 people were thought to have infected themselves in Berlin clubs. Some of those were club-hopping, spreading the virus as they went.

“This is the attitude of people who are part of this nightlife,” said Lutz Leichsenring, a director of the association of Berlin club owners. “So what? You get the flu, you’re not going to die.”

Last week, German Chancellor Angela Merkel herself, in her first press conference on the epidemic, urged young people to respect the new social restrictions for their grandparents’ sake.

Despite the pointed fingers and occasional excesses, many young people bristle at the accusation of selfishness, saying the new social constraints are disproportionate and unfairly target their generation.

“They’re preventing us from living,” said Timothée Thierry, a 30-year-old statistician at France’s health ministry. He spoke on Sunday, after the government shut down bars but before it locked down the entire country.

In Italy, which has been on lockdown for days, young people, especially students, face a choice between returning to their parents’ homes or remaining cooped up in small apartments, desperate for a social outlet.

One student in the Piedmont region of northwestern Italy said she sneaked out of her apartment to attend a dinner party because she was feeling depressed from days of isolation. The party was only a 10-minute walk away. Once there she joined four other people, drinking wine and eating around the dinner table.

Just before midnight, the police knocked on the door and asked for the identification cards and phone numbers of everyone in the group. They ordered the revelers to return home, warning them that their information was being kept on file. Each person was subject to a hefty fine or jail-time for attending the party, the police said, according to the student.

Some say they are less frustrated by the prospect of extreme confinement than they are doubtful it could ever work in the West, which prizes individualism and freedom.

“If I get sick, I will spend some days at home to avoid spreading it to others,” said Monica Rubio, 19, who was having a late breakfast with three friends late last week in Barcelona, Spain, one of Europe’s most heavily affected countries.

“Otherwise I won’t change my life because of it. I can’t imagine people would stop shaking hands, kissing or hugging. It is deeply entrenched in our society.”

© Christian Murdock/Associated Press In Asia, there have been fewer complaints from authorities about younger people flouting social-distancing rules, but with the epicenter of the pandemic now shifting to Europe, the sense of urgency, palpable at the peak of the Chinese epidemic, has begun to recede in the East.

Mong Kok, a busy shopping hub in Hong Kong’s Kowloon district, has been noticeably busier than in previous weeks, with many young people tentatively returning to their pre-coronavirus weekend routines. Despite the greater crowds, many youthful bystanders still wear surgical masks and keep hand sanitizer close to hand, even attached to rucksacks.

“I think it’s quite boring staying inside. Teens and young people you see, they’re stuck at home and out of the office. It’s quite hard,” said Hailey Cheng, 27, as a street performer tried to fire up a lackluster audience nearby.

On a recent night in the semiautonomous city, Peel Street, a thoroughfare lined with bars and popular with expats, thronged with hundreds of maskless drinkers. A band played in the lower half of the street, where people stood shoulder to shoulder.

“I stayed at home for two months. I’m not staying any more,” said Ryan, 26, who was walking with his friends down the main strip of nearby Lan Kwai Fong, a series of streets filled with bars and clubs. “Life goes on.”

“We worry,” said Nicole, 25. “But either you worry yourself to death or you drink yourself to death.”

Write to Bojan Pancevski at bojan.pancevski@wsj.com and Stacy Meichtry at stacy.meichtry@wsj.com