Try with this UsercustomJSActions.
Create .js file with this code http://bexgordon.com/2015/10/use-javascript-to-change-the-logo-of-sharepoint-site-to-the-site-collection-url/
_spBodyOnLoadFunctionNames.push("SetHomeLink");
function SetHomeLink()
{
var siteCollectionUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
var oldLogoId = $("#DeltaSiteLogo > a").attr('id');
$("#" + oldLogoId).attr('id','CustomSiteLogo');
$("#DeltaSiteLogo > a").after("<a id='tmpDeltaSiteLogo' href='#' style='display:none'>Dummy</a>");
$("#tmpDeltaSiteLogo").attr("id",oldLogoId );
$("#CustomSiteLogo").attr('href', siteCollectionUrl);
}
for var siteCollectionUrl
you could set ~sitecollection/
Inject JavaScript
https://www.tonyishere.co.uk/tag/javascript-injection/
#Run all of your lines to load the context of the site collection
$context.Load($site)
#add custom js injection action
$customJSAction = $site.UsercustomJSActions.Add();
$customJSAction.Location = “ScriptLink”;
#reference to JS file
$customJSAction.ScriptSrc = “~SiteCollection/Style Library/JS Display Templates/test.js”;
#load it last
$customJSAction.Sequence = 1000;
#make the changes
$customJSAction.Update();
$context.ExecuteQuery();
Change the location that the site page logo points to
https://stackoverflow.com/questions/13582710/sharepoint-redirect-site-logo-link-to-the-root-site-collection-home-page