The mention of rocks or stones crying out is found in the context of the triumphal entry—Jesus’ entrance into Jerusalem a week before He was killed. Jesus rode on the back of a borrowed donkey’s colt, and multitudes of people praised Him as the “king who comes in the name of the Lord” (Luke 19:38). When the Pharisees in the crowd heard the people’s worship directed at Jesus, they said to Him, “Teacher, rebuke your disciples!” (verse 39).
The Pharisees had to know they were powerless to stop the excitement of the people, so they called on Jesus to stop what they believed to be blasphemy.
Jesus replied, “I tell you, . . . if they keep quiet, the stones will cry out” (Luke 19:40). What did Jesus mean by this statement? Did He mean that the rocks would literally start shouting praises to the Lord? Most likely, no. The expression the stones will cry out seems to be proverbial and isn’t to be understood as a literal statement. The meaning seems to be that it is more likely that the impossible would happen than for the King of kings to enter His capital city without honor.
In saying that the stones will cry out, Jesus indicates that the people’s acclamations should be encouraged, not suppressed. The people of Jerusalem are expressing great joy, and that joy is so appropriate, so necessary, that, if they did not express praise, it would be appropriate for inanimate objects to fill the void. Colossians 1:16 says that all creation was made for God’s glory. Everything in creation declares His praise. However, humans are created in God’s image (Genesis 1:27), so we are the ones who should be praising God.
Shortly after Jesus’ triumphal entry, the people would keep quiet. And, by Friday, they would yell for Him to be crucified (Luke 23:18–23).
The idea of rocks crying out in praise to the Lord is poetic, startling imagery. Throughout Scripture are similar poetic passages that present inanimate objects praising God. For example, in Psalm 114:6, the mountains leap. Isaiah 55:12 says, “You will go out in joy and be led forth in peace; the mountains and hills will burst into song before you, and all the trees of the field will clap their hands.” Throughout Psalm 148, there are numerous examples of created things praising their Creator—the sun, moon, stars, heavens, water, sky, animals, and people. Everyone and everything was created for the pleasure of the sovereign Lord.
Source: https://www.gotquestions.org/rocks-cry-out.html