I don't think you have correctly grasped how the Plugin can be used to override a function. In your example there is nothing to connect the function toggleTables with the Indexer class you are trying to override.
I haven't done exactly what you are trying to do so this will require you to do some more reading to get it to work for your circumstances and maybe someone else can provide an exact or working example, however these are the parts you need to have.
To start with your Plugin should be written to register the file where your override code can be found and this is done by registering the library early on in processing, in this case just after things get initialised.
use Joomla\CMS\Plugin\CMSPlugin;
class plgSystemFinder_override extends CMSPlugin
{
public function onAfterInitialise()
{
JLoader::register(location of your version of the toggleTables function);
}
}
More information here; https://docs.joomla.org/Using_own_library_in_your_extensions/en and https://forum.joomla.org/viewtopic.php?t=984541 to help you decide how you want to find your version of the function.
You also need to install your version of the code for the function into Joomla so the the above plugin can find it. Unless you have some other extension as part of your changes then I would say look at installing it as a Library.
<?xml version="1.0" encoding="utf-8"?>
<extension type="library" method="upgrade" version="4.0">
<name>My Test library.</name>
<libraryname>mytest</libraryname>
<files>
<folder>Classes</folder>
<folder>language</folder>
<filename>mytest.php</filename>
</files>
</extension>
More information here, https://docs.joomla.org/Manifest_files towards the bottom discusses Libraries. You could also look at Package Manifests to combine the the Plugin and the Library to be installed together.
And finally you need to perform the actual override in your code so you would have something like this in the code you have installed in the Library in the previous step so that your code will be called instead of the core code.
##Updated in response to the comment by @sharky
class Indexer
{
entire contents of Joomla\Component\Finder\Administrator\Indexer.php including your changes
}
However this answer is incomplete as I now understand we need to replace, rather than override/extend, the entire Class but I am not sure what needs to be done in the plugin to replace the core class that is already loaded.