Yes you can use "by" two times in a sentence if needed.
If sentence is
1. I learn this poem by heart. (Active Voice)
1. This poem is learnt by me by heart (Passive Voice)
Another example could be:
I will submit the documents by tomorrow. (Active Voice)
The documents will be submitted by me by tomorrow. (Passive Voice)
I hope this would help
Regards