How do I create a WP sandbox for development on localhost (raspberry pi 4) without being redirected to the live site?

You need to change the url of the copied website to not have a redirection

Assuming your live url is https://oldurl.com and your sandbox url is http://mysandboxurl.com (replace the values with your actual urls)

You can do so with either a define in your wp-config.php

define( 'WP_HOME', 'http://mysandboxurl.com' );
define( 'WP_SITEURL', 'http://mysandboxurl.com' );

Or changing the option_value of siteurl and home to http://mysandboxurl.com in your wp_options table

Or using wp cli

wp search-replace https://oldurl.com http://mysandboxurl.com --all-tables

To replace all links in your content as well to avoid being redirected via your menu to the live website