How can I change a texture globally in a material function?

You can actually use a custom function to do the same thing at runtime.
Optimizing dynamic landscape materials doing this (although a bit of a nightmare) worked very well for .24

Basically the landscape default stuff always uses texture samples.
Using the custom node you can try (because it’s not always a guarantee) to stop that from happening when layers aren’t painted in at all.

You can find some info along with the flames here

Using a static parameter will definitely work with the a custom node containing an if and 2 inputs.

Using a scalar may or may not depending on who knows what.

As I said there (or if not I’ll say it here now again) there was a definite performance benefit when checking if a layer painted and valid or not for landscapes.