Changable favicon

If you have a modern theme, where you can upload a favicon with the theme customizer (rather than a hardcoded url in the header.php), you can simply use a filter. Take a look at the function get_site_icon. As you can see it returns the url of the image that you have uploaded using the customizer. However, before it does so, it runs it through a filter, allowing you to change it under any condition you would like. For instance, to change it when you are on a page with ID=3:

add_filter( 'get_site_icon_url','wpse318165_filter_favicon', 10, 3 );
function wpse318165_filter_favicon ($url, $size, $blog_id) {
  global $post;
  if ( is_page( 3 ) ) $url="path-to-other-favicon";
  return $url;
  }