Safe push button hacking
Set D0 to '0' and never change it. Instead, change the output enable (e.g. PB1DIR or pinmode(D0, OUTPUT) when you want to close the switch.

You're limited on how much resistance you can put in series and still get a valid logic value. If you make sure it is unambiguously a '0' and use 0.8V as a threshold, then you need the resistor to be less than 1k. Based on your current limit of 12mA, maybe a 330 ohm resistor would be sufficient to offer some protection while still giving a reasonable output voltage.

I don't think the resistor is necessary for proper operation.