Can I get a prescription for B12 through my doctor?

Probably not. It will be difficult to convince them. They'll likely just tell you that you don't need B12. Or they'll say that you can just take B12 supplements because they think that's good enough. 

Some might give you a prescription for B12. However, they often prescribe the inactive forms of B12, which are not as effective as the active forms. They really don't know anything about these differences between the different forms of B12.

And then they will often only agree to prescribe you just one shot every few months, which is definitely not enough.  

So I wouldn't rely on them. It will be a hassle to deal with them. You’re better off just ordering what you need online.