S.B.'s post is right -- if you lock him in, he will stand there at his locked door panicking: He cannot get out, he does not know where you are, and believe me, in his very young mind he will truly think you and daddy have gone away and left him (even if you talk to him through the door). Locking the door sends a message that you are done with him and will not come if he calls, period. Young children need to know that their parents will come if something is wrong. Locking him in would not teach him more independence; it would teach him that he is utterly alone and cannot rely on you. A child who is responded to actually is more secure and later, more independent, than a child who feels cut off or not responded to; children get more, not less, insecure if left shut away.
So, what to do?
You do indeed need to walk him back to his bed. Over and over and over. But it must never be in a way that gives him any attention; it needs to be utterly boring. He gets up; you do not speak to him or scold; you silently walk him to his bed, put him into it, and walk away. If he follows: Do it again. Yes, you will have some VERY long and sleepless nights. But if he gets any scolding, any fussing from you or dad, if you cave and he gets in your bed or sleeps on your floor -- that is attention, and you must withdraw attention. This is game to him; even negative attention like scolding is still a reaction from you, so deny the reaction. He needs to learn that getting out of bed GETS him nothing but a silent return to bed and that the game is now very, very boring.
If you must change him: Do it as silently as possible; don't chat to him through it. I would really look into workiing so that he has a good pee before bedtime; cutting out liquids after dinner or even from late afternoon onward; and getting better, more absorbent diapers, so you do not have to change him at night. He may be coming to your bed at night partly because he's half-awake due to his body telling him it's just about to pee - that semi-wakes him and he stumbles to mom's familiar bed, and then he wets. If his nighttime wettings are in the middle of the night (not early on when you are still awake), try this: Before you go to bed, after he's been asleep a while, you get him up (no lights on, no talk, just peel him up to his feet) and steer him to the potty (if he's doiing the potty thing) and have him pee, then walk him back to bed. That kept my daughter dry at night, and she never remembered it-- she was so sleepy that she just automatically peed and returned to sleep and it didn't disturb her. If he is not potty training yet -- please look at your routines and ensure he is getting less liquid as the day goes on, etc. as above.
You have a dual issue here of nighttime wetting and keeping a child in a toddler bed. Neither is fun BUT both are very typical -- you are not alone and this will not last forever, though that is hard to believe now! Please realize that you will have to return him to his bed over and over but it wont' go on eternally.
Another strategy is to put him to bed more gradually: Stay in the room as he falls asleep (no talking, stories, etc. after lights out; just your silent presence). Then after a week or more, you move to the hallway, sitting where he can see you through his cracked door. After a few nights, or a few weeks, you stay there for only five or 10 minutes then go when he's slightly awake. This gradual process worked for our kid when she was this age and starting in a toddler bed; she never did the constant getting-out routine because she knew we were there for her.
But please, please do not lock him in a room. Remember -- for kids this young, they sometimes believe that if they can't see you they aren't quite sure you still exist! Also, locking him in will teach him to stay there, yes, but it will teach him through fear and panic; it will last longer, and make him more secure overall, if you teach him through the disciplined approach of returning him. It is not fun and dad may object but if you don't do the work, you'll have him back in your bed again.