The short answer is yes, you can. One way to test if your coconut has gone mouldy is to shake it. If you can’t hear any liquid sloshing around inside, the coconut milk has probably gone rotten. However, fresh coconuts (which are light brown) may be so full of water that the liquid doesn’t seem to move, so beware.
You should also check that there is no whiteness on the coconut, which indicates that the inner has gone mouldy and altered the outer appearance of the coconut. Black spots on the top or bottom of the coconut can also indicate a similar problem. When buying a coconut, always check there are no cracks as these can indicate that air has got inside and the inner coconut area will have been exposed, causing mould.