If you live in a jurisdiction where sodomy is criminalized, then that is an intolerable situation which should not be allowed to stand. Even if you personally are smart enough to get away with it then undoubtedly there's some poor innocent who isn't going to get away with it. If you find yourself in a situaion like that you're morally obliged to either:
a) Leave, or
b) Actively campaign to change that law. If you choose to do it via civil disobedience then good luck to you... otherwise just get to work on campaigning.