It is a very important and critical question. In astrology, there are certain permutations and combinations which helps one to analyse whether one will go prison or not.
When the Sun or the Moon is weak or debilitated occupying the 8th house and has some connection with the 6th house, there will be imprisonment. Mars too may bring in imprisonment. Strong Saturn will bring in only political imprisonment. If the 8th house is weak or afflicted, there will be a imprisonment. The dasa periods of the weak or debilitated lord of the 8th is a period of prisonment and prison life.
It is very important to know the major and the sub-period and the sub-sub period of the planet to predict imprisonment. We have seen that sometimes even the innocent person has to spend a night in prison. So it is better to take prevention.
Proper gemstone and remedies can help a lot to get out of this fear.