I don't know if he used sonnets in the play at all, but he wrote sonnets alongside the play, to parallel and give voice to Hamlet's letters to Ophelia known as the "Ophelia Sonnets":
Check out this website for explanation: http://www.hamletregained.com/Ophelia_Sonnets.html
Here's a sample:
Ophelia's Love Sonnet (#70)That thou art blamed shall not be thy defect,
For slander's mark was ever yet the fair,
The ornament of beauty is suspect,
A crow that flies in heaven's sweetest air.
So thou be good, slander doth but approve,
Thy worth the greater being wooed of time,
For canker vice the sweetest buds doth love,
And thou present'st a pure unstained prime.
Thou hast passed by the ambush of young days,
Either not assailed, or victor being charged,
Yet this thy praise cannot be so thy praise,
To tie up envy, evermore enlarged,If some suspect of ill masked not thy show,
Then thou alone kingdoms of hearts shouldst owe . . .
This is the speaker's apology to Ophelia regarding the slander he spread.
Also, look at this previous Q/A regarding Hamlet and Sonnets:
Critic and poet T.S. Eliot, who called the play Hamlet an "artistic failure," says that the sonnet and drama are at almost two mutually exclusive ends when it comes to art. He says that drama is a public show, but the sonnet a private meditation. In particular, he called Shakespeare's sonnets thusly:
full of some stuff that the writer could not drag to light, contemplate, or manipulate into art.
So, the sonnet is a kind of stand-alone poem that cannot be brought out on the stage for public view.