This is a terrible match up for poor Bowser Jr... Don't feel bad losing to Sonic with Bowser Jr.
Unfortunately, the heir to the Koopa throne doesn't have too many options for stuffing Sonic out of his mix ups. The Koopa Walking Bomb thing I find to be more useful when a confirmed SD/SC as it's chargining (Sonic may cancel this though) as it forces Sonic to not SD/SC towards you. However, like you said, Sonic can simply grab it, or depending on timing and distance, simply still SD/SC you. Also, recovering is a nightmare for Bowser Jr against Sonic. If you recover Horizontally with Forward B, you can easily get BAired/FAired by Sonic. If you recovery with Up B from under the stage, the spring will stuff you and you have no more Up B and simply fall to your death.
What the poster above me said is true as well though. Bowser Jr's up B is good for stuffing Sonic's SC/SD if you can react in time. However, Sonic can simply jump early to hit you in the air or SD Cancel and run in and shield the Up B opening you to punishment.