1. He wrote a letter with a pen.

2. He wrote a letter in a pen.
3. He wrote a letter in pen.

4. He was writing a letter in pencil/in fountain pen/ in a ball-point pen.

(Is #2 incorrect? Why is that? Is #4 all correct? Do we have to delete 'a' or'an' after 'in'?)

3 answers

1 and 3 are correct. 2 is not. He was in an animal pen or a child's playpen when he wrote "in a pen"?

We would properly say he wrote with the writing instrument (pen, pencil, etc.). To say he wrote "in" pen or pencil, etc., is less formal and more colloquial, but we do say it. It means the same thing.
He wrote a letter
He wrote the letter with pencil