I got it. I found this old post Accessing role object from template, and the solution is to call RT::CustomRole-1
instead of the role name, ‘1’ being the ID of the custom role.
return 0 unless $self->TransactionObj->Type eq "Comment";
return 0 unless $self->TicketObj->Status eq "approval";
my $thisEmail = $self->TransactionObj->CreatorObj->EmailAddress;
# Get list of email addreses in the "Approvers" custom role by ID.
# Custom Role Approvers ID = 1
my $ticketApprovers = $self->TicketObj->RoleAddresses('RT::CustomRole-1');
return 0 unless $ticketApprovers =~ /$thisEmail/;