An employee whose religious practices prohibit payment of union dues to a labor organization cannot be required to pay the dues, but may pay an equal sum to a charitable organization. If you do not object to all of the union's work, but merely the portion spent advocating in favor of a cause you do not support, another possible accommodation is discounting your union dues by a fraction of the amount of money spent on the union activity you do not agree with.
If this is part of your religious beliefs, you should let your employer and your union know this so that dues will not be withheld from your paycheck, and also make the appropriate arrangements for either paying your dues to a charitable organization or making a discounted dues payment.