When Bernard Sanders, a socialist, was elected mayor of Burlington, the local newspaper called it ''a fluke.''

Local T-shirts and the Doonesbury comic strip immortalized ''The People's Republic of Burlington.'' When socialist Francois Mitterrand was elected president of France, Doonesbury creator Garry Trudeau said, ''As goes Burlington , so goes France.''

More than a year later, no one's joking anymore.

The head-on clash of socialism with Vermont's crusty Yankee individuality has ignited political fireworks that may eventually explode far beyond the borders of this city of 39,000 on the shores of Lake Champlain.

Sparks may fly at the bitterly divided Board of Aldermen meetings that local Democratic leader Brian Brennan calls a circus, but Mr. Sanders has the State of Vermont not only studying new ways for cities and towns to raise tax money, but also pushing for it to consider some tentative first-steps toward socialized medicine.

''Because of his position as the mayor of the largest city in the state, he's got influence,'' admits Mr. Brennan. And in an interview with the Monitor, Sanders said his aim is to set an example statewide.

Sanders is popular in Burlington. When he defeated longtime Mayor Gordon Paquette in 1981, local political experts predicted that voters would repent, see the error of their ways, and bounce the unswerving political radical from office.

Instead, voters put three more Sanders supporters on the Board of Aldermen. And with the next mayoral election only six months away, Brennan says, ''Right now, Sanders is probably the strongest candidate.''

Much of his record so far is not too different from standard party-brand city mayors. He has won Burlington hearts by promoting inexpensive culture for the masses, starting a new baseball team in the poorest part of town, and cleaning up questionable insurance contracts to save the city some $300,000.

His hard line against what he sees as the powerful and extravagant medical profession helped play a part in the withdrawal of both Burlington and the Vermont League of Cities and Towns from Blue Cross-Blue Shield to a private health-care insurer. He has the league forming a legislative package to regulate health-care costs statewide, and he plans to push for a $4 million state donation to subsidize tuition for students at the University of Vermont's medical school so the state can then hire the young doctors to start a public health service to pay off their subsidy. He wants to move even further toward socialized medicine, but he says he realizes his views are more radical than those of most Vermonters.

Voters also loved his refusal to agree to Lake Champlain waterfront development consisting largely of expensive condominiums, a hotel, and boutiques.

''Those proposals would make the waterfront exclusively for the wealthy,'' says Sanders. He says he wants the firms who snag the development rights to also provide public amenities for mass enjoyment, such as a maritime museum.

But how did a hard-working town in conservative Yankee country find itself with one of the few socialist mayors in America as the rest of the country continues to veer toward the political right?

''Complacency,'' says Brennan.The political establishment was caught napping. Neither major party bothered to tap the political power of the huge influx of largely liberal and well-educated ''ex-urbanites'' from Boston and New York who migrated to the Vermont hills during the 1970s.

But Brennan is sure the movement that brought in Sanders will be history in 10 years. Sanders ran as an independent in coalition with aldermen members of the independent Citizen's Party.

''The track record of third parties is that they're an answer to a specific need and the major parties tend to absorb the new one,'' he says. ''Some of the Citizen's Party voters are hard-core leftists, but many are Democrats who will come home when they see the welcome mat.''

When Sanders won election by a mere 10 votes, he became the only socialist mayor in the US, although Santa Cruz, Calif., has since followed suit in the fall of 1981 by voting in a socialist mayor. It wasn't that he hadn't tried before: two runs for the governorship and two for the US Senate since he moved to Vermont in 1970. After a dozen years here, his rapid-fire speech still echoes his native Brooklyn. There's not much of the Vermont wood-smoke smell about him: His horn-rimmed glasses label him ''intellectual,'' his gray hair is a shock of tangled curls.

Describing the state's conservatism as the ''leave-me-alone'' brand, Sanders also points out that ''Vermont is one of the poorest states.'' He gives the ''disintegrating economy'' credit for boosting his victory. They saw then Mayor Paquette as ''head of a small clique running City Hall only in the interests of the business community.'' Sanders says it's been a constant political battle with his opponents ever since.

But there's ''a good chance'' he'll run for reelection in March. Others suspect he'll parlay his mayoralty into a higher office. Gruffly waving off any question of where he might go after his stint as Burlington mayor, Sanders says: ''Too early to tell.''