The simple answer is, yes you can!
However the main thing you should consider is how elaborate you want to get and how much money you want to spend.
If you literally want to record a single song just for the fun of it, I imagine you do not want to set up a full blown recording rig in your living room. However if you are seriously considering setting up a home studio you will want to consider your purchases carefully allowing for future expansion. If that is the case I would suggest you do a little more research before you buy anything.
But lets start with the basics. There are a few things you need to be able to record something onto your computer.
Microphone(s) To be able to capture an acoustic signal such as
your voice or drums
Microphone preamplifier To convert the output signal of the mic
to line level
Audio interface Or a sound card, to convert the analog signals produced by a mic, a guitar amplifier or a keyboard to a
Recording software To record the digital signal to your hard drive
and allow you to edit and mix your recording(s)
All of these things come in many shapes and sizes and with price tags ranging from $20 to thousands of dollars. Many of these products also combine functionalities. For instance most sound cards or USB interfaces have onboard preamps and you can even get USB microphones which have both a preamp and an interface built into them.
If you are on a budget I would recommend the latter. Blue microphones and Samson both make several affordable and decent quality USB microphones. Combine these with a free software package like Audacity (or Samson also offers some of their mics bundled with a basic version of Cakewalk Sonar) and you have everything you need to do some basic recording and mixing.
However using a USB mic only allows you to record one track at a time so you will need to record all your instruments separately. Or you can just put the mic in the room while everyone plays their instrument at the same time but then you will not be able to edit or mix the individual instruments.
If you want to be able to record several things at the same time but still have them all be individual recordings you will need an interface with multiple inputs (note, not all "multi-channel" sound cards have multiple inputs, some only have 1 stereo in an multiple outs for surround). You would probably also need more than one microphone and obviously more cables.
Another option is to plug your mics into an outboard mixer, do your mixing on there and then record the stereo output of the mixer into your sound card. But again, this will not give you as many mixing and editing possibilities as when you record all the instruments to individual tracks.
One final thought. Whilst using professional equipment clearly has its advantages; the most important ingredient in a "good quality" recording is the person doing the recording and their ears. If you know what you are doing you can produce very decent sounding stuff using very little means. There is a plethora of information available online, countless free tutorials and many forums where professionals and experienced hobbyists share tips and tricks.
Do a few searches and spend some time reading up on recording and mixing techniques. Regardless of what hard-/ software you end up using, I guarantee it will improve your recordings!