There’s a 12/3 existing wiring in my hallway that runs up to the light fixtures. I want to extend the 12/3 wiring to a bedroom to add a smart switch and recessed lighting. If I pigtail 12/3 from the power in going to the light switch in the hallway and send the cable to the bedroom to a smart switch would that work?
First thing is you need to determine if that box (picture) is two circuits with a shared neutral, called a MWBC. You weren't clear what lights are on that box, and what lights you are going to have on the smart switch. I presumed the smart switch is going to control the recessed lights and all that is going to be in the bedroom? What do you have to test voltage with? (How much is already on the circuit/circuits?) If it is split (MWBC), then you will only be using one circuit (a hot and a neutral). Warning, you must have BOTH circuits turned off before you do this (or you can blow something up on the live circuit! You could also get electrocuted.
Do NOT mistake the red wire in your box (pic) for the Red wire in a smart switch diagram!
[UPDATE-adding question (can't comment yet, until I get 2 more up-votes)]
Did you mean 12-2 wire? 12-3 has a black, red, and white wire; 12-2 has black and white. 12-3 w/g (with ground) has black, red, white, and bare ground. If you mean 12/2 G, then your project makes more sense to me.
Also, mostly curiosity; is that box (pic) mounted on a stud? It looks like the drywall is patched on all four sides. I would recommend adding 'F' clips, but the plaster ears are not on that box,as far as I can tell. (and that patch looks wafer thin anyway at the ear ends.) So does the switch fit in that box? Looks like it is in another box, no room here, and no pigtails visible...
If you meant 12/2, then my advice above is still applicable.
@FreeMan Thanks for the assistance, fixed those in my post.