Drupal 8 provides a useful helper funciton $entity->toLink(..). You must return it by converting to a string by using ->toString() at the end.
public function foo(Request $request = NULL) {
$id = $request->get('id'); // from query string
$entity = YourEntity::load($id);
$message = $this->t('Check at @url.', [
'@url' => $entity->toLink('<TEXT_TO_LINK_HERE>', 'edit-form')->toString(),
]);
return [
'#type' => 'markup',
'#markup' => $message,
];
}