The short answer
Yes. In February 1513, three months after losing his job, he was arrested, held twenty-two days, and put to the rope six times.
Why he was arrested
Two young men were plotting against the restored Medici. One of them, Pietro Paolo Boscoli, had written down the names of people they thought might join them, and Machiavelli's name was on the list. No document decides whether he was in the plot; the modern editors of his letters think it unlikely. While he was inside, the two plotters were beheaded.
The rope
The rope, or strappado, meant being hoisted by the wrists, tied behind the back, and dropped. From the cell he wrote comic sonnets to Giuliano de' Medici, the man who could open the door: a pair of irons on his leg, lice the size of butterflies, and six drops of the rope on his shoulders.
Getting out
What freed him was an election. The cardinals chose Giovanni de' Medici as Pope Leo X, Florence celebrated, and the prisons were emptied. His first letter as a free man asks a friend to keep him in the memory of the Medici, in case they had any work. He mentioned the rope in prose once afterwards, as a unit of measurement: a gloomy letter from the same friend had frightened him more than the rope.