Zardnaar
Legend
We know that some droids can. That means that any droid potentially can.
We see the opposite - C3PO does impersonate a deity. And gets into a forbidden escape pod. And do a whole things they are "programmed" not to. They protest vociferously, wave their arms in the air, and do it anyway without any ill effects.
And it's easy enough to cite examples of individual humans who will always obey orders. It only takes one example of free will to demonstrate the capacity for free will.
No one would intentionally program Chopper or L3 to behave that way (or intentionally program 3PO to be so irritating for that matter). As for "malfunction" that is how evolution works. An unplanned change. "Your free will was a mistake, get back in your box" is a pretty obnoxious argument to say the least.
C3PO didn't break his programming though. Luke made him float around.
We don't know that about programming gem. In legends yes they were programmed like that. Or side effect if not deliberate.
I don't think Disney's gone into enough detail.