If Billy Batson time travels to the past or future and says "Shazam" will he still be transformed? I tried to Google the question and did not find an answer.
The answer is "yes", his power still works.
The only instance where I can produce evidence for comes from the run of Justice Society, circa 2002. In the story, Hawkwoman, Mr. Terrific, and Captain Marvel are all thrown deep into the past to ancient Egypt. There they fight Vandal Savage and Ahk-Ton, perhaps the original Metamorpho born of the Orb of Ra. Our Heroes find allies with a relatively newly-made Black Adam, the sorcerer Nabu, and the original Hawkman and Hawkwoman.
Trying to find help, Adam and Captain Marvel travel to the celestial realm. There, they use the power of their transformation to hopefully attract the attention of the god Ra.
As you say, there are so many re-re-reboots and variations of Captain Marvel/Shazam, I'm sure there more examples of the power working and others claiming it does not.