Eugene Debs, a Socialist leader in the early 20th century, ran for President five times. His fifth and highest vote count came in the 1920 Presidential election, in which he was running while in Federal prison for sedition. He received about 3.4% of the vote at the time (which included women for the first time since the Nineteenth Amendment was passed in 1920 as well). Not naming names, but yes, it’s possible to run for President while in prison, though results may vary.