Nope, you're doing it wrong.
Point number one: You can jump while holding shield.
Point number two: grounded upB is a thing that is possible. See (for one) Link, who has dramatically different upB properties depending on whether he's grounded or in the air.
Point number three: in order for grounded upB to be possible, and tap jump to be possible, you have to be able to perform an upB while in jumpsquat (which is that little startup animation between hitting jump and actually leaving the ground).
What this all means is that you can jump while in shield, and you can upB while in jumpsquat.
Therefore, in order to upB out of shield, you don't have to let go of shield--you just have to jump (easiest with tap jump in this case, so that your control stick is already pointing up) and then immediately input an upB.
In other words, you literally do upB out of shield the same way you do upB while standing. Again, you don't have to let go of shield.
Upsmash OOS works the same way, by the way (tap up on control stick, and then before you leave the ground tap up on the cstick, or tap A I guess but I prefer cstick for that). It's just not as useful for Marth.
EDIT: Guess I should throw in this caveat: when your opponent hits your shield, you go into what's called shieldstun, where you're stuck holding your shield for a tiny bit. You can't upB OOS or really do anything at all until shieldstun ends. So don't try to upB too early! Of course, it takes 5-6 frames for the upB to come out, too, so if you're too late you'll just get hit... it's tricky! But still useful.