The answer to the title question might well be "yes":
At the start of WWII, the French mathematician André Weil, a pacifist, was charged with failure to report for military duty, and was imprisoned in Le Havre and then Rouen. During his prison time he proved the Riemann hypothesis for curves over finite fields. The letter he wrote from prison to his sister on his research is printed in translation in A 1940 Letter of André Weil on Analogy in Mathematics. Weil describes how he could do math in prison in his autobiography: "Life is a composite of trivial details: perhaps this becomes clearer in prison than anywhere else. [...] I am thrilled by the beauty of my theorems."