Five months before the nation's first election test in New Hampshire Sen. Edward M. Kennedy, even as a write-in candidate, has strengthened his lead over both President Carter and California Gov. Edmund G. Brown Jr., according to a poll taken for The Boston Globe.

If the Democratic primary were held today, Kennedy, as a write-in candidate, would win 58 percent of the vote compared to Carter's 28 percent and Brown's 11 percent, with 3 percent undecided.

Although Kennedy loses some support because of Chappaquiddick, the poll shows that he loses more because of an image as a "big spender."

The poll was conducted between Sept. 7 and 11, as a Kennedy candidacy began to move from an uncertainty to what some see as a probability. The findings assume that, as a write-in candidate, Kennedy would not go to New Hampshire to campaign.

When half the 688 Democratic primary voters sampled were reminded of the death of a woman in Kennedy's car at Chappaquiddick 10 years ago, and of the fact that he lives apart from his wife, Kennedy's margin over Carter dropped five points.

When the other half of the Democratic sample was reminded that Kennedy favors a number of costly "bigspender" government programs, and of inflationary arguments against them, his margin over Carter dropped by 12 points.

This suggests that Kennedy is more vulnerable to Carter in other sections of the country on the big-spender label than on Chappaquiddick.

The only way Carter could win the key initial primary, the survey suggests, would be for Kennedy to announce that he would not be a candidate and also to disavow any write-in activity on his behalf.

Only then does Carter nose ahead of Kennedy, with the results Carter 41 percent, Kennedy 31, and Brown 19. Kennedy still would get almost twice the 16 percent he got in a similar category in May. This may suggest that more voters feel Kennedy will be a candidate.

Since the similar survey in May, Brown seems to have lost a bit of ground.

When voters were asked which is more important to them, a candidate's stands on issues or his ability to get things done, they opted overwhelmingly for strong leadership.

Sixty-five percent said ability to get things done was more important, 17 percent chose stands on issues, 14 percent said the choices were equal, and 4 percent said they didn't know.

Among those who emphasize stands on the issues, Kennedy leads Carter by less than 3 to 2. Among those who stress effectiveness as a leader, he leads by more than 4 to 1.

Seventy-seven percent of the sample said the right candidate for president could bring the nation's problems under control; only 13 percent said problems are too big for any president to handle. This would seem to suggest New Hampshire Democrats reject Carter's argument that there is a crisis of confidence in America.

In a three-way matchup, Kennedy gets 68 percent to 20 for Carter and 9 for Brown with 3 percent undecided. If Kennedy's name were not on the ballot, he would still get 58 percent in a write-in to 28 for Carter and 11 for Brown.