Yes, you can. However, it’s always worth considering your transport plans if you’re only travelling very short distances, regardless of the type of fuel your vehicle uses.
Diesel buyers are typically advised to avoid only doing shorter journeys because their engines use a diesel particulate filter (DPF), which can clog in these circumstances, potentially leading to a costly failure. DPFs need the diesel car to run regular longer journeys to give them a chance to reach high temperatures, allowing them to burn off captured particulates in a process called regeneration.
Petrol cars do not use DPFs so are not at risk from this specific type of failure. However, it’s still important to remember that you cause the most wear to your engine when it’s cold and, if you don’t give it the chance to properly warm up every so often, that can accelerate the rate at which internal components fail. Very modern petrol engines now feature their own GPFs (gasoline particulate filters) but their higher exhaust temperatures and lower overall particulate emissions compared with diesel means they’re much less likely to get clogged.