In your specific case, you need two variables. Player_HP and Player_HPMax. Both starts at 100.
Set HP bar sprite width to ((Player_HP / Player_HPMax) * 100).
When you upgrade, raise the Player_HPMax to 300. So if the player health is 100/300, the bar width is 1/3 of 100 pixels only. Until you raise the Player_HP.
You can also apply that to enemies or npcs too if you want to scale their health but keep the bar the same width max.
Hope that helps you.