If you're worried about an unfriendly judge, and you don't have anything against you that a judge has a legitimate reason to deny your name change for (e.g. a criminal history, large debts), you might try giving an "alternate" reason and not mention that you're trans. A back-door reason like "I don't like my present name" or "I think the chosen name better fits my personality" is perfectly acceptable if you don't have any of the aforementioned strikes against you (you could even say if true that you've been using the name you're changing to informally for awhile and want to make it legal).