I want to change src of icon used in SharePoint search template.
But error is coming that .attr is not a function. Am I missing something here?
From your screenshot I see the first line $(".cbs-ItemLink img") is returning HTML as an output but it should return an Object as follows

If it returns an object then you can use any functions of that object.
There might be 2 reasons for your issue
Try to execute with following syntax to get additional information
jQuery(".cbs-ItemLink img")
jQuery(".cbs-ItemLink img").attr("src","/")
When jQuery says something (on an object) is not a function, the object itself (your DOM element in this case) is not there
With SP Search, the results HTML is coming in async, so you can't query for something that is not in the DOM yet
To do it right you can monitor DOM changes, but that is senior level JavaScript programming.
window.setTimeout function to delay execution of your code and every cycle check if your required DOM element exists
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>