I doubt if a 401k could be used as collateral for a loan from a 3rd party since they would have no way to recover that money on default (exempt from bankruptcy). Your employer can at least deduct it from your paycheck. I know that it is illegal to use an IRA as collateral for a loan.
The employer typically sets any rules about borrowing from a 401k, and if you are no longer employed there, the loan becomes immediately due and payable (or would be considered a distribution with applicable tax/penalty). Even though the interest is paid to yourself, the entire loan is paid back with taxed dollars. For these reasons, borrowing from a 401k is a bad idea.
You could probably get a better interest rate elsewhere if it is for something with collateral, which may be tax deductable if used for your home (not deductable for any reason if borrowed from 401k).