The best defense is a good offense. If you can drive your enemy out of lane or at least give them a reason to want to stay away from you, you'll be able to avoid harass. Know when to fall back, don't get greedy and try to farm with 1/5 health.
A big factor of laning is predicting your enemy's actions. It can be tough, but imagine how easy laning would be if your enemy shouted out their plans. If you can read your enemy, you can make the lane yours. With that said, try to ruin your laning opponent's plans. Harass just BEFORE they move in for a last hit, try to pay attention to if and when they go for runes and try to stop them. It's something you'll get the hang of eventually.
One last thing, a bottle almost always ensures a won lane. Heroes with sustainability also to a great job of helping with this, too (Omni, Kotl, Necro, Undying). If you're concerned about a lane, try to get a healing or high-damage support.