No, you cannot use a Ugandan gorilla trekking permit to trek in Rwanda or a Rwandan gorilla trekking permit in Uganda. This is because the countries’ gorilla trekking permit prices, policies, arrangements, and governing laws/rules are different. Also, Gorilla trekking permits are issued to 8 or 10 people per gorilla family a day, so if you have not booked with the specific country; you will not be allocated a family to visit.
This applies to the Democratic republic of Congo too and the Gorilla trekking permits in Congo.
You cannot use a gorilla permit issued in country A in country B.