You sure can, although sometimes it is easier than others. On my last couple of laptops it was as simple as changing a setting or two in software.
I had one laptop that ran XP and the settings in software had no effect. Closing the laptop put it to sleep no matter what, till I chopped off the little pin that detected the closed lid...