Depends on whether it’s a non-refundable or fully refundable flight ticket. If it’s a fully refundable ticket, then yes. You can cancel and receive a full refund of your flight ticket in case your visa is refused.