As long as you identify your role and capacity, and as long as you answer truthfully, the recipient may give it the weight he or she considers appropriate. However, check with your mentoring faculty member or department chair before writing one.
If you agree to write a letter for a student, there are considerations regarding authorization, defamation, etc. You should certainly not provide a negative reference unless the subject of the reference has specifically and in writing released persons providing references from liability of any kind, including defamation. If you are inclined to give a negative reference, you may wish to consider disclosing that to the requesting student and letting the student decide whether he or she still wants you to write a reference.