Then why wasn'y Janeway court-martialed when she gave to go ahead to Worf to use a cloaking device.
Because, as others have mentioned above, the RSE was no longer a superpower at that point. It didn't matter so much if the Federation angered or offended the Romulans, as the Romulans were not in a position to pose a true threat.
That's not true. As stated above, a treaty has the force of law for either nation that is a signatory to it, regardless of the status or actions of the other nation. If Janeway gave an order violating UFP law, that would mean she was answerable, not to the Romulans, but to the Federation itself.
It's possible that the treaty or law is written to allow exceptions in case of extreme emergency, so long as the cloak is not used against any of the signatories; that's how the use of a cloak aboard
Defiant could be justified (though Sisko did stretch the letter of the law considerably when using the cloak in the Alpha Quadrant). The use of a cloak against the Borg may have been permissible under the same exemption, though it's likely that Janeway would've had to submit to a hearing in order to prove the necessity of her order.