Given schemes $X,Y$ and $Z$ such that $Z$ is a closed subscheme of both $X$ and $Y$ the pushout exists in the category of schemes. So in particular one can glue schemes along a closed point or glue a scheme to itself along a pair of closed points (although one needs to choose a subscheme structure - you would want to take the reduced induced subscheme structure probably). A reference for this (carried out via the category of locally ringed spaces) is given in <a href="http://www-personal.umich.edu/~kschwede/SchemeWithoutPoints.pdf"> this</a> paper of Schwede (Corollary 3.9). In general though the pushout in the category of locally ringed spaces need not be a scheme even if one pushes out along a subscheme - see for instance Example 3.3 in Schwede's paper.