Comedy, tragedy, and drama are subtle and tricky-- smart people like Aristotle have tried to figure it all out and no one has really definitively nailed it. And even Aristotle wasn't worried about role-playing games. But based on observation, here is what I think.
First and foremost, in order to play a serious character well, you and your character need something serious to act against: Either the overall setting needs to be serious, or the setting at least needs to have serious moments. This might not be as obvious as it seems at first blush, though. I think most people would agree that a religious war is a serious thing... but I could be wrong. Consider the two following passages.
First:
“It was in that year when the fashion in
cruelty demanded not only the crucifixion of peasant children, but a
similar fate for their pets, that I first met Lucifer and was
transported into Hell; for the Prince of Darkness wished to strike a
bargain with me.
-- The War Hound and World's Pain, Michael Moorcock
Second:
Once I saw this guy on a bridge about to jump. I said, "Don't do it!"
He said, "Nobody loves me." I said, "God loves you. Do you believe in
God?"
He said, "Yes." I said, "Are you a Christian or a Jew?" He said, "A
Christian." I said, "Me, too! Protestant or Catholic?" He said,
"Protestant." I said, "Me, too! What franchise?" He said, "Baptist." I
said, "Me, too! Northern Baptist or Southern Baptist?" He said,
"Northern Baptist." I said, "Me, too! Northern Conservative Baptist or
Northern Liberal Baptist?"
He said, "Northern Conservative Baptist." I said, "Me, too! Northern
Conservative Baptist Great Lakes Region, or Northern Conservative
Baptist Eastern Region?" He said, "Northern Conservative Baptist Great
Lakes Region." I said, "Me, too!"
Northern Conservative†Baptist Great Lakes Region Council of 1879, or
Northern Conservative Baptist Great Lakes Region Council of 1912?" He
said, "Northern Conservative Baptist Great Lakes Region Council of
1912." I said, "Die, heretic!" And I pushed him over.
-- Emo Philips, stand up comedy routine
The first is from a novel set during the Thirty Years' War, a horrifically destructive religious war in Europe. The second is from a late 20th century stand up comedian. It's perfectly possible (and a perfectly valid choice, subject to tastes of the group) for a GM to subvert a serious background and play it for laughs.
If that's what the GM actively wants out of his or her game, you have a real challenge on your hand.
Second, and very closely related to the first, you need co-players who broadly support-- or at least tolerate-- your desire for moments of a serious tone. Comedy is tricky, and no one has properly nailed it down, but one definition I find persuasive and explanatory (if not perfect) is that comedy stems from the incongruity between expectations and results. Which means, if you play with an expectation of seriousness and the other players simply don't accept it, that incongruity itself can become comedic. (Specifically, your character might become a type of straight man.)
Third, and finally, some concrete suggestions on (my paraphrasing) playing a serious character without either being overwhelmingly grim (i.e., entertaining) or degenerating into a clown:
It's hard to sustain overwhelming seriousness all the time, either as a person or in drama. A movie or a play is one thing, a long form TV serial or RPG is another. It is also hard to be overwhelmingly serious about everything. Consider having one or two particular things that the character considers not funny, and play it that way.
This works best, I think, when the GM is active and on-board, so that situations can be presented with reasonable pacing between them-- too much is overwhelmingly grim, too little can see your character's default become comic. It also works better when they stem from the character's past, either background from before the game, or develop in-game.
If it's serious enough and not overplayed, Tranquil Fury can be an effective manifestation. Several examples at that site are from notionally comedic or light-hearted characters, ranging from the cosmic (Doctor Who) to the borderline downtrodden (Dan Conner.)
If the notion of being serious about only one or two things doesn't seem like it's "enough" consider also that humor is also a defense mechanism, and that this is the mechanism that has driven some of the most successful dramedies of the 20th century. I am thinking specifically of MASH, but even more than the series I am thinking of the characters. Especially Hawkeye, a surgeon whose comedic defense mechanism against the horrors of modern war was almost indistinguishable from insanity... but when the time came, no one could question his commitment to medicine.
Fourth and finally, because so much of this depends on the mood of the GM and players, I would strongly encourage talking to your GM and the to other players in that order. It may be that you are not the only one in this situation of wanting to be serious but feeling trapped by a group dynamic. (Or the opposite-- but either way, knowing will help.)