Unless you're hacking, the personality value (which is part of what determines shininess, along with OT ID) will never change. The only way a Pokemon could lose or gain shininess is if its OT ID gets changed, and in the actual games, that only happens under two situations.
First is the Shadow Pokemon in Colosseum and XD. When initially generated, they get a random personality value and the OT ID of the trainer who owns them. When Wes/Michael snags them, the game overwrites the OT ID with that of Wes/Michael (mainly so it doesn't act like a traded Pokemon).
Because of this, it is possible for a Shadow Pokemon to be shiny before snagging it, but lose it upon being caught. It's also possible for a Shadow Pokemon to suddenly become Shiny when you catch it.
But, of course, XD and Colosseum are side-games. What about the main series games? Well, there's a similar situation that happens with eggs.
When generated, eggs will be given the OT ID of whoever obtained the egg. This will later be overwritten with the OT ID of whoever hatched the egg. However, the weird thing is that this occurs after the hatching animation.
This means that it is possible for traded eggs to be shiny in the hatching animation (if its personality value and the original breeder's OT ID results in it being shiny), but then not actually be shiny (if the hatcher's OT ID results in it not being shiny), or vice versa.
This mechanism used to be (and possibly still is) the only way to get a shiny Manaphy. Back in the original Pokemon Ranger, you could get a Manaphy egg to send to Diamond and Pearl. When the egg is transferred, the game is programmed to continue to reroll its personality value to ensure that it will never be shiny; however, you could get around this by trading the egg to a different game, because hatching doesn't modify the personality value.