How do I display a link icon in custom modules?
You can convert markup with image tags and convert it into URL with image like below:

use Drupal\Core\Render\Markup;

$imgsrc = Markup::create("&lt;img src ='$base_url/scp/sites/default/files/images/corr_icon.gif'&gt;");
$correct_link = Url::fromUserInput('/answer/'.base64_encode($data-&gt;ans_refno).'by'.base64_encode($data-&gt;q_id));
'isanswer' =&gt; \Drupal::l($imgsrc, $correct_link),