A wall fills a specified number of contiguous squares within range, starting from an origin square.
Each square of the wall must share a side—not just a corner—with at least one other square of the wall, but a square can share no more than two sides with other squares in the wall (this limitation does not apply when stacking squares on top of each other).
You can shape the wall however you like within those limitations. A solid wall, such as a wall of ice, cannot be created in occupied squares.
Published in Player's Handbook, page(s) 272.