What does "a riff on Shakespeare" mean?
One source of the word riff is the music world, in which it's not uncommon for a musician to take a tune s/he has heard, and then perform a little variation on that tune. It happens all the time in some jazz sessions.
To "riff on Hamlet," then, would be for a person to take a line from the Bard and play with it, explore it, have some fun with it, look at it in various ways, explore it for levels of meaning and possible connections to other concepts and ideas, and so on.