In "Hamlet", how are Rosencrantz and Guildenstern loyal to Claudius?
Though he can't remember their names correctly, Claudius summons Rosencrantz and Guildenstern to Elsinore so that, under the guise of friendship, they can investigate Hamlet's madness:
The need we have to use you did provoke
Our hasty sending. Something have you heard
Of Hamlet's transformation—so call it,
Sith nor the exterior nor the inward man
Resembles that it was.
They're loyal to Claudius because they obey him to the letter, interrogating Hamlet and reporting back to Claudius about him, though - by not being as bright as Hamlet - they do get caught out by Hamlet in the first scene they have with him. They try to play him, as he says after the play scene, like he is a pipe. But they are, of course, being loyal to their king.
There's an early sign of their loyalty when they rather toadily praise the king for asking them, rather than commanding them, to talk to Hamlet:
Both your Majesties
Might, by the sovereign power you have of us,
Put your dread pleasures more into command
Than to entreaty.
But we both obey,
And here give up ourselves, in the full bent,
To lay our service freely at your feet,
To be commanded.
Loyal servants of the crown, indeed.