Add customized code to Shopify theme
I haven't used shopify so I don't know if you can accomplish your task with fewer shopify calls, but I do find it a little odd that the URL in the second call requires redundant theme identification.  I mean, the theme id is in the path and the querystring. 

Outside of that, I spy some basic refinements.


As a general rule, avoid declaring single-use variables. Reasonable exceptions to this rule include when:


the merging of multiple processes/declarations results in a code line which exceeds a sensible length (horizontal scrolling is a drag and I generally obey PHPStorm's visual guide line when deciding when a line is too long) or
the data being processed/produced/declared is clarified by the variable name

Within a given project, determine if variables will be written in camelCase or snake_case.  Use one style consistently throughout.
There is no JSON_PRETTY_PRINT for json_decode() -- you are looking for the true parameter to make an array.  The outcome is the same, but it is a typo worth fixing to avoid future confusion.
Write a space between all comma-separated parameters in functions.


Application:

$themeList = shopify_call($token, $shop, "/admin/api/2019-07/themes.json", array(), 'GET');
$themeList = json_decode($themeList['response'], true);
$themeId = $themeList['themes'][0]['id'];
$themePath = "/admin/api/2019-07/themes/{$themeId}/assets.json?asset[key]=layout/theme.liquid&amp;theme_id={$themeId}";

$customTheme = shopify_call($token, $shop, $themePath, array(), 'GET');
$customTheme = json_decode($customTheme['response'], true);
$currentTheme = $customTheme['asset']['value'];
$pos = strpos($currentTheme, "&lt;/body&gt;");
$str = "{% include 'back-to-the-top' %}\n";
$currentTheme = substr_replace($currentTheme, $str, $pos, 0);


In conclusion, I reckon only the PRETTY_PRINTing, variable formatting, and the spacing should be changed.  The choice of how/when to declare data is mostly about personal taste.