In Shakespeare's Hamlet, Gertrude does, indeed, do exactly as Hamlet asks her to by telling Claudius that Hamlet is as mad as the wind and sea when they contend, etc. And she certainly could be demonstrating loyalty to her son and attempting to protect him. Hamlet gives her a direct order, and she does as he orders.
At the same time, one should be aware of another way of interpreting her behavior and words. In short, Gertrude may tell Claudius that Hamlet is mad, because she thinks he is mad--and one could hardly blame her.
Look at Hamlet's behavior and words while he's alone with his mother in Act 3.4:
- He is so aggressive toward her that she thinks he's going to hurt her and she cries for help: "What wilt thou do? Thou wilt not murder me?/Help, ho!"
- He kills Polonius, thinking it is the king, for hiding behind the arras and listening in.
- Sees a ghost.
- Repeatedly harps on Gertrude's sex life. Hamlet seems obsessed with his mother's sex life.
- Says he is not really mad, but is just pretending, and that Gertrude should keep that a secret and not let Claudius get that truth out of her when he touches her sexually.
Gertrude can be faulted for other things in the play, but she can't be faulted for thinking her son is insane. She may be covering for him when she tells Claudius he is mad--this lessons Hamlet's responsibility for killing Polonius. But she may also just be telling Claudius what she sees as the truth--that Hamlet is, indeed, mad.
One of the central questions of this play is whether or not Gertrude loved King Hamlet and was simply wooed or pressured into marriage with Claudius, or if she already had some kind of relationship with him before the murder and perhaps was even somehow complicit in getting rid of him in order to marry Claudius. That issue, as well as the haste with which she remarried, is at the root of the Hamlet-Gertrude relationship and conflict. Just as Hamlet is never really sure about his mother's loyalties, neither are we. However, we do know that after Hamlet confronts her with a picture--literally--of both men, she is somehow broken and contrite about what she's done. After this meeting, she does seem to ally with her son, at least to some degree. Here's how we know it:
Despite having just committed the accidental murder of Polonius, Hamlet does reveal to her that his "madness" is only an act, and he asks her not to tell. When she leaves him and goes straight to the King (Act IV scene i), she does tell about the murder but she continues the charade of Hamlet's madness.
"Mad as the sea and wind when both contend
Which is the mightier. In his lawless fit,...
And in this brainish apprehension kills
The unseen good old man [Polonius]."
She attempts protect her son with the lie that he is, indeed, mad.