Can you run a D&D game for one player? Sure. Do you have to do it differently? Yes.
However, here’s the good news: it’s 95% the same as running for a group.
First off, ask the player what he or she wants to accomplish during his or her session. Depending on the player, you can focus this conversation on actions or goals. Some players will tell you that they want to kick some butt in combat and maybe have a little role-playing; others will list one or two objectives they want to mark off.
Second, build the session around the player’s character. Look at the PC’s character sheet, and make a quick list (in your head or written down) of the character’s specific abilities, strengths, and weaknesses. Then tailor the session’s scenario to the character, also keeping in mind what the player told you.
For example, a utility character with high bonuses in Investigation and Survival may not get much of a chance to use those skills in a combat-heavy group, but can really come into its own in a session built around a mystery or exploring a remote area.
Third, build combat encounters with only 1-2 enemies. The action economy will destroy a lone PC targeted by multiple creatures, so it’s best to keep encounters small. This actually works really well in a solo session, as the player can really focus on a single monster and make it special.
Finally, build and offer 1-2 player-directed NPCs, but don’t insist on them. These NPCs can go along with the PC and assist him or her, acting as extra “party members.” Offering helpers can reassure a player who’s nervous about heading out alone, but can feel like a crutch to others. So, don’t force the players to use them. Build your encounters for solo PC combat, but also such that you can add a few enemies to challenge a PC accompanied by one or two helpers.
And when you go into the session, have fun! Solo sessions tend to be much more dramatic and feel a lot more like a book or movie than a typical D&D session. Savor the opportunity to tell a very directed story about a single hero!