I realized the reason it doesn’t work: this function needs to be located in functions.php.
Per WP code reference: pre_get_posts
“Fires after the query variable object is created, but before the actual query is run.” Since I placed the function within an archive template, the main query had already fired, and was thus too late.