Is there any difference in politeness or formality between the following sentences?
- Please can I borrow your pen?
- Can I please borrow your pen?
- Can I borrow your pen, please?
No, I wouldn't say so. To make it more polite, you should substitute "may" for "can".
"May I please borrow your pen?"
In a polite question, "can" tends to connote ability or possibility, e.g. "Can you run a five-minute mile?" "May" connotes permission, as in your sentence.
Please can I borrow your pen? Can I please borrow your pen? Can I borrow your pen, please?
The biggest factor is the tone of your voice. Sadly it is impossible to show that satisfactorily via text.
Depending on the company you keep, 'may' is considered politer than 'can' (see Albatrosspro's answer)
In British English, I would probably say, "Can/could/may I borrow your pen please?" The other two versions can be used as a sign of impatience, e.g.
To a stranger
Could I borrow your pen please?
To a friend
"Can I borrow your pen?"
"Huh?" [friend is playing computer game]
"Can I borrow your PEN please?"
"What?" [friend still isn't listening]
"PLEASE can I borrow your PEN?"