You must have at least eight, and less than ten players to play full court. A minimum of two players to play half court.
Forming teams. The two teams should have about equal scoring and equal defensive abilities. Knowing the players is helpful. Just looking at individuals and determining skill levels is problematic. If scoring is lopsided, some players might have to switch teams for purposes of competitive balance.
Basketball is a game that was seemingly designed to initiate arguments. So enjoying a pick-up game can be tricky, or it can be very simple. It can be simple if all players have the same mindset as far as a competitive spirit that allows players to play with determination, but yet a competitive spirit that fall short of going into the area of being overly competitive and combative.
Rules. Where I play pick-up basketball there is of course no actual referees. So there is a rule that if a player is fouled (and it's always an offensive player fouled) play is stopped and that player's team simply inbounds the ball, resuming play. It is a kind of "honor system". As a purist, I beleive that whoever came up with this system should be shot and then subsequently hung (no foul, of course). When an offensive player is fouled, that player has in essence won the small battle-within-the-battle that is basketball. It really doesn't matter if the foul in question is intentional or not. For example; if player "A" is driving to the basket with the ball, beating defensive player "B", and "B" reaches out to steal the ball only to catch "A"'s arm, player "A" won that mini battle and should be rewarded in some manner. I maintain that the second team foul within a given possession should count as a scored basket. With this rule fouls will be less common and play will be stopped less often. And of course the better effort will be properly rewarded. The only drawback is that some lesser skilled players foul just to be competitive. Kind of a handicap system. This type of "handicap fouling" would no longer be feasible, which might be a concern in a casual game amongst friends who have a wide range of basketball skills.
As for scoring, most games are played to a given score. The first team to reach that score wins. Generally scoring is done by 1's. Some players like to use the 3-point circle with any shot made beyond that arc counting 2, or double a normal basket. Personally I prefer to use the arc but most players do not.
Games are played to 8, 12, 15, or even 21 at times. This depends on climatic conditions, the number of players courtside waiting to play, and the overall physical stamina of the players.