Yes, God does teach both believers and unbelievers through suffering. More on this in a moment, but first it’s worth emphasizing that not all suffering is from God (e.g., sometimes suffering is brought by other humans: cf. 1 Sam. 26:19) — so, just because someone is experiencing suffering in their life, it doesn’t mean that God is trying to teach them something through it (although, of course, we can learn things from all the experiences we face). But back to answering the question…
Hebrew 12 makes is clear that God teaches believers things through suffering. In v6, for example (quoting from Proverbs 3:12), it says:
For the Lord disciplines the one he loves, and chastises every son whom he receives.
A dramatic example of God teaching unbelievers through suffering is when he brought the plagues on Egypt. In regards to the first plague, for example, Moses tells an unbelieving Pharaoh (cf. Ex. 5:2) the following:
Thus says the LORD, “By this you shall know that I am the LORD: behold, with the staff that is in my hand I will strike the water that is in the Nile, and it shall turn into blood.” [Ex. 7:17