This sounds like Menalaus' encounter with Proteus. Menelaus narrates it in Homer's Odyssey (book 4). Proteus' daughter advises Menelaus to go grab Proteus and not let go even though he changes his appearance. Menelaus goes as he was advised, and seizes him, and Proteus changes into many forms, but Menelaus and his men don't let go, and in the end he is forced to provide Menelaus with the information he wanted.
"'First he [Proteus] will look over all his seals, and count them; then, when he has seen them and tallied them on his five fingers, he will go to sleep among them, as a shepherd among his sheep. The moment you see that he is asleep seize him; put forth all your strength and hold him fast, for he will do his very utmost to get away from you. He will turn himself into every kind of creature that goes upon the earth, and will become also both fire and water; but you must hold him fast and grip him tighter and tighter, till he begins to talk to you and comes back to what he was when you saw him go to sleep; then you may slacken your hold and let him go; and you can ask him which of the gods it is that is angry with you, and what you must do to reach your home over the seas.' (Odyssey 4.411-424)