The gender of an avatar. To change the gender of your avatar, enter the Edit menu on top of your Second Life window and choose Appearance.... When your shape is modifiable, you'll find an option to switch your gender from female to male and vice versa in the lower left of the new window. Save your change and close the window to continue your Second Life with a new gender.
The gender is stored for every shape individually. So you can easily switch by storing different shapes in your inventory.
Changes of your shape are not reflected in agent information you can query by scripting or profile pages.
Press CTRL-ALT-SHIFT-D on your Windows or Linux PC (CTRL-OPT-SHIFT-D on a Mac) to enable the Advanced Menu. In Advanced > Debug Settings..., search for the AvatarSex variable. This variable equals 0 (default) for female and 1 for male. It can also store higher values than 1. Changing the AvatarSex value in the Debug Setting will not effect the gender of your shape, but the other way around (change in the shape influences the variable).