Main problem of showing progress bar in Blender UI is that while a script is running the UI is frozen. So the simplest (?) solution is to break execution whenever the progress status should be updated. For this you can use either timers or modal operators. The last one can't be switched on during all time of Blender execution and has some starting costs.
import bpy
from functools import partial
def show_progress(area):
if show_progress.iteration >= 100:
area.header_text_set(None)
return
else:
area.header_text_set(f'Loading {show_progress.iteration}%')
show_progress.iteration += 0.5
return 0.01
show_progress.iteration = 0
bpy.app.timers.register(partial(show_progress, bpy.context.area))
Haven't tested, but what I'd try is the following:
First, the place to show your variable/message is:
area.header_text_set(f'Loading {show_progress.iteration}%')
Since
bpy.app.timers.register(partial(show_progress, bpy.context.area))
is registered once, I'd guess we can not pass a parameter with our variable/message. So, what I will try is to have a global variable with your message. You edit/update that variable in your code as you want.And then:
In theory will get it and print it. (Again, not tested but is what I'd try)