If you are closing your position before the expiry, the difference between premium paid to buy the option and premium you will receive upon closing the position will be your P&L. Just like it is with stocks, where difference between buy and sell price is the P&L.
If you are not squaring-off the position and letting it expire. Then, if the option is ITM (Spot Price > Strike Price), it’ll be settled at intrinsic value (Spot Price - Strike Price) and the difference between buy price and settlement price will be your P&L.
If the position is OTM (Spot Price < Strike Price), the option will expire worthless and you will lose the entire premium paid.
Do check out this post for more information: What happens if I don't square off my positions in options? - #2 by ShubhS9
Would also suggest you go through this module on Varsity for deep dive into options: