Zend certified PHP/Magento developer

How to add a custom email variable to magento 2 credit memo email?

I need to add a custom variable based on payment method to credit memo email.

I captured the event email_creditmemo_set_template_vars_before in my custom module, Which was dispatched on MagentoSalesModelOrderCreditmemoSenderEmailSender.php.

I need to add my custom variable showrefund to bellow set.

$transport = [
            'order' => $order,
            'creditmemo' => $creditmemo,
            'comment' => $comment ? $comment->getComment() : '',
            'billing' => $order->getBillingAddress(),
            'payment_html' => $this->getPaymentHtml($order),
            'store' => $order->getStore(),
            'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
            'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
            'order_data' => [
                'customer_name' => $order->getCustomerName(),
                'is_not_virtual' => $order->getIsNotVirtual(),
                'email_customer_note' => $order->getEmailCustomerNote(),
                'frontend_status_label' => $order->getFrontendStatusLabel()
            ]
        ];

I added the following code in my observer file.

public function execute(MagentoFrameworkEventObserver $observer)
{
    $transport  = $observer->getEvent()->getTransport();
    $order          =   $transport['order'];
    $orderId        =   $order->getEntityId();
    $orderStatus    =   $order->getState();
    $payment = $order->getPayment(); 
    $method = $payment->getMethodInstance();
    $methodTitle = $method->getTitle();

    if($methodTitle == "Cash On Delivery"){
        $showRefundAmmount = "0";
    }else{
        $showRefundAmmount = "1";
    }
    $transport['showrefund'] = $showRefundAmmount;
    return $transport;
}

This way the additional attribute is not working. I tried below way in the same file

$transportObject = new DataObject($transport);
$this->templateContainer->setTemplateVars($transportObject->getData());

This part also not doing the trick.

How can i add this custom variable to the email template. Can anyone help me in this question.