For a site using CiviCRM profiles you can opt to use Joinery's Profile Conditionals extension and adapt the conditions to which you want this behavior to occur.
For it be checked with any price field selected, an example is below:
<?php
$civicrm_setting['com.joineryhq.profcond']['com.joineryhq.profcond']['contribution']['all'] = array(
'01_auto_renew_is_checked' => array(
'conditions' => array(
'all_of' => array(
array(
'selector' => 'input[name="price_7"]',
'op' => 'is_checked',
),
),
),
'states' => array (
'pass' => array (
'selectors' => array(
'input#auto_renew[type="checkbox"]' => array (
'properties' => array('checked' => TRUE),
),
),
),
'fail' => array (
'selectors' => array(
'input#auto_renew[type="checkbox"]' => array (
'properties' => array('checked' => FALSE),
),
),
),
),
),
);
Change out the price field (price_7) with yours. There are many ways to change the conditions based on your use case, you can find instructions on those options here.
I put this in it's own profcond.settings.php
file in case you make a syntax error and want to quickly deactivate the conditionals to prevent it from breaking CiviCRM. Add include __DIR__ . '/profcond.settings.php';
to civicrm.settings.php
file for this setup.
Also noting that recently there was a change in core that displays / unchecks the "Please renew my membership automatically" option when selecting a price option so using the "onload" option exclusively no longer works (tested 5.65 where that last worked).