You could do it with jQuery:
jQuery(document).ready(function($) {
$('a[href*=#]').on('click', function(event){
event.preventDefault();
});
});
Save that to a file (something.js) and upload it to your server. Then add the following to your functions.php (remember to set up a child theme if you aren’t using one):
add_action( 'wp_enqueue_scripts', 'prefix_load_scripts' );
function prefix_load_scripts() {
wp_register_script( 'something', get_stylesheet_directory_uri() . '/path/to/file/something.js', array('jquery'), true );
wp_enqueue_script( 'something' );
}