No. The intentional targeting of innocent civilians who posed no direct threat to the Allied soldiers is never justified. Yes, I know the consequences of an invasion would have been worse, but targeting civilians like this is never ok regardless of the consequences.
I think the best answer is the blockade.
A blockade would have killed much more civilians than the nukings did lol it would last months possibly Years.
That would be the Japanese government killing them, not us. This forum may be full of consequentialists but I am not one.