Solution:
Although it’s not a best practice to write html in controller and it should be done in a blade file, you can use concatenation to use route() method within a string like below code:
route()
return '<a href="'.route('test',$id).'">Button</a>';