The short answer is: yes, you can drink the tap water in Portugal. It isn't as nice as tap water from other parts of the world (Ireland and Scotland, for example), but it's perfectly safe to drink. You'll see plenty of Portuguese people buying bottled water, but that's just because it tastes nicer.
Alternatively, some people who live in Portugal long-term invest in a Brita filter. This takes away the unpleasant taste, and means you don’t have to buy as many big plastic bottles of water. The filters last around 2 months each, and you can buy them in bundles from Amazon and in the supermarkets as well. If you’re just visiting Portugal, a Brita Filter would probably take up a lot of room in your suitcase, so go for one of the travel Brita Filters instead.
If you don’t have any bottled water or a Brita Filter, add a squeeze of lemon juice. It hides the flavor somewhat.