I think it would be more accurate to say that the US government notified Japanese government but nobody expected the warning to be taken seriously.
I personally believe doing this is morally no different from just dropping the bomb without warning. Because nobody expected the warning to be taken seriously. Because there was no precedent, because the bomb was developed in complete secrecy, because there was no proof or demonstration to the Japanese government that the claim is real for them to take it seriously.
It is essentially just looking for an excuse for your actions without really honestly trying to avoid using the bomb and deter your enemy. There is a lot alternative ways US could use those bombs without dropping them on densely populated areas.
They could drop it on an unpopulated area and tell "we have more of these". They could drop it on any military installation or grouping of forces that is a bit further away from a populated city. They could explain they have the bomb and invite a representative for a demonstration.
At this point Japan had no capability to prevent US from overflying its territory so it is not like Japanese could do anything to prevent the bomb dropped. Knowing a bomb so powerful was developed and ready they would have no choice but surrender.
Instead US chose to send a signal to everybody at the cost of tens of thousand of lives that were lost only for the purpose of making that signal so much more powerful.
Telling Japanese to evacuate was really completely meaningless move with no moral implications.