Keser Rosh(132) An aveira Leshma has not been permitted at all from the time of the giving of the Torah otherwise why have the 613 Mitzvos
Horayos (10b) A transgression with good intent is more meritorious than the performance of a commandment with no intent; for it is said, Blessed above women Jael be, the wife of Heber the Kenite, above women in the tent shall she be blessed. Who are the women in the tent? Sarah, Rebeka, Rachel and Leah.
Nazir (23b): A transgression performed with good intention is better than a precept performed with evil intention.
https://minchasasher.com/shiur/parsha-shiurim/aveira-good-intentions-5776/
It would have seemed from this Gemara that one has an open license to commit an Aveira if one has a good intention in mind. However, Rav Chaim Volozhiner[5] flatly rejects such an interpretation. He says that if that were the case then there is no need for 613 Mitzvos. All one would need is good intentions; there would be no need for a structured list. He therefore says that once Torah was given that is the absolute rule. Only before Torah was given, and during our time to the B’nei Noach, there is permission to act in accordance to what seems to be correct, even if it’s an Aveira. What about Ya’el? To that he has two answers. Firstly that she knew and perceived deep Kabbalistic secrets pertaining to this relation. But none of us nowadays have such knowledge. Secondly, it was done to save all of Klal Yisrael.
The Ramchal[6] has a similar opinion to Rav Chaim Volozhiner. These Gemarahs play no practical role nowadays. Ya’el’s actions were a specific ruling due to deep Kabbalistic reasoning.