'A friend in need' is ambiguous in meaning.
It could mean the friend is in need. Which makes the saying more difficult to explain ( though not impossible as some of the slightly tortuous examples given show) .
The simpler explanation is that the other person is being a friend in your time of need . Then it makes sense . Eg (someone who is ) a friend ( in a time of ) need is a friend indeed