Can I ask for a LOR from a teacher that didn't teach any of my classes?
The general rule when it comes to letters of recommendation is that you should not ask for a letter from someone who does not know you well.

In this particular case, it's not sufficient that the professor you want to ask knows you. It is more important that he knows your work well, and can comment on that to graduate schools regarding your potential as a future student in their program.