Okay, there's quite evidently a whole lot to unpack here. First off, how did this thought make way to your head? It's interesting. Considering that we all have basic sex knowledge.
Second, if you want to know this - you could've just googled it, you know? You don't have to type it out on Quora to wait for months for an answer.
And to answer your question - I don't think you can. At least, not to my knowledge. But let's get into the logistics.
So here's the groundwork - if you get knocked up, you've probably acquired semen of some sort from somewhere. Without that, pregnancy may be off the table.
Sex toys are basically used for self-pleasure or masturbation. So simply, dildos are not real penises - they're made of rubber or other stuff that can't really produce semen. But, there's a catch.
Some dildos do come with a semen like substance filled in them. It's definitely not semen, but it does give you the same feeling. The dildo is just stuffed with it - so maybe the feeling is better. Who can tell? Only you.
But recently, a new kind of dildo has hit the markets specifically targeted towards lesbians or others who can't conceive a baby with a man. It's called a POP dildo, and it's like any other high-end dildo, except it ejaculates real cum. It comes with a "specifically designed inner tubing embedded in the shaft with an attached pump."
You draw up the liquid of your choice — maybe it's lube, maybe it's semen — into the tube. Then, when you're ready to "ejaculate," squeeze the pump, and the liquid squirts out.
Basically, using a dildo to please yourself is the same as using a banana to please yourself, unless it's a POP dildo or a banana peel with a penis attached inside it - you are definitely not going to get pregnant.
So, if I have answered your question, I suggest you head-on with your sex toy endeavours with zero worries and just have some fun.