Once you beat the game, you'll unlock Theater Mode. To get the Secret Ending, you have to get a certain amount of trophies depending on your difficulty setting.
Next, you need to answer the three questions that were asked to Riku at the end correctly. The answers are:
1. Losing something that's important.(Option 3)
2. My friends.(Option 2)
3. To find something important.(Option 2)
Afterward, you need to unlock the Secret Message during the credits by collecting the gold letters during Sora's credit Dive. It will spell out "Secret Message Unlocked."
Once you save your end-game file and reload it, you should get a prompt saying you unlocked the Secret Ending in Theater Mode.