They will be exposed to the sun and the moon and all the stars of the heavens, which they have loved and served and which they have followed and consulted and worshiped. They will not be gathered up or buried, but will be like refuse lying on the ground. Jeremiah 8:2
Before them the earth shakes, the sky trembles, the sun and moon are darkened, and the stars no longer shine. Joel 2:10
Immediately after the distress of those days “‘the sun will be darkened, and the moon will not give its light; the stars will fall from the sky, and the heavenly bodies will be shaken.'" Matthew 24:29
A great and wondrous sign appeared in heaven: a woman clothed with the sun, with the moon under her feet and a crown of twelve stars on her head. Revelation 12:1
Sometimes the sun, moon and stars represent the idolatry of the Bible. People worshipped those things in the sky and believed those things impacted their destiny.
Other times, in the case of Joel and Matthew, they are talking about, in context, the destruction of Jerusalem or Israel.
This imagery all started with a dream Joseph had about the stars, moon and sun.
Then he had another dream, and he told it to his brothers. “Listen,” he said, “I had another dream, and this time the sun and moon and eleven stars were bowing down to me.” Genesis 37:9
Joseph saw his family bowing down to him in a dream. That prophecy came true when he was made a leader in Egypt.
So the stars, moon and sun also represent the twelve tribes of Israel or Israel. In Revelation, it specifically says a child was born out of her and that child was Jesus.