Can you do that if you're homeless? (I don't know for sure - my local library doesn't say either way except for the statement "living in or owning property in [my area]").
Depends on the library, and perhaps on when you ask. The Cambridge Public Library web site now says they require a "current local address", so the homeless may be out of luck. But they used to require only that you be able to sign your name. (This was advertised with posters featuring a very dejected looking cat.)
It must depend on a lot on the library, which must depend a lot on the city. I have read of cities in New Jersey winding up in litigation over trying to push out the homeless essentially camping there. I believe that a co-worker used to complain of the homeless crowding the main DC library.