Yes coconut oil does work great for skin whitening and can be used as a natural sunscreen to protect your skin from the sun.
I've used coconut oil on my skin to help with skin whitening and it worked great but it took a few months of using the coconut oil every few days to see the results fully.
Just massage the coconut oil into your skin and leave it on your skin without washing it off and do that every few days for a couple months.
After a month or two you should see whiter skin but sometimes you might see whiter skin sooner depending on how your current skin tone is already.
Some other good oils for skin whitening are Grape Seed Essential Oil, Lavender Essential Oil and Blackcurrant Seed Essential Oil.