The Chayei Adam (Klal 63, ois 4) writes: “I found in a sefer, whose name I forgot, that one shouldn’t tell his friend that he has seen a rainbow, due to the principle of: מוציא דבה הוא כסיל - “Sharing bad news is foolish”. The Mishnah Berurah (Orach Chaim 229) brings this down l’halachah.
The question is, the halachah is (Yoreh Deah 402:12): “If one’s relative dies and he doesn’t know about it, there is no obligation to tell him - even if it is his father or mother. About such a thing we say, מוציא דבה הוא כסיל - “Sharing bad news is foolish”. However, the Rema writes: “The custom is to inform male relatives that their father had died and there is no problem of, מוציא דבה הוא כסיל - “Sharing bad news is foolish”, as there is a purpose in doing so, as he can say kaddish.” We see that when there is a purpose it is ok to share bad news. If, so, why don’t we say the same thing by a rainbow, and one should be able to tell others so that they can recite a berachah on it?
R’ Yosef Chaim Sonnenfeld (Shu”t Salmas Yosef 204) answers: By the case of the niftar [the person who passed away] there is a great purpose, as the male relative can say kaddish. In the case of the rainbow, however, it could be that by the time the friend looks it will have gone, and it comes out there was no purpose.
However, the sefer Bris Kehunah (Ma’areches 100, ois 3) writes: The accepted minhag is that if one sees a rainbow, he is allowed to tell a friend so that his friend can also make a berachah on it. He writes: This is not included in the rule of מוציא דבה הוא כסיל - “Sharing bad news is foolish”, because, on the contrary, we are giving blessing and thanks to the Ribbono Shel Olam for His great kindness that He isn’t going to destroy the world. In fact, it’s better to tell others, in order that they do teshuvah, and better their ways.
The Chasukei Chemed (Berachos 59a) writes: If one hints to his friend then it is ok. For example, he asks him where a siddur is so that he can say the berachah. He cites proof from the Gemara in Pesochim (4a) where we find that if one hints at the fact that a certain person dies, it’s not included in מוציא דבה הוא כסיל - “Sharing bad news is foolish”.