You get the gold, and the city it was stolen from (which you live in, and find the gold hidden below) wants it back. They're willing to let the party keep as much as 10% of it (finder's fee, so 50k), but the rest they want returned.
If you don't want to give it back, then the book does say yes, you can attempt to keep it, but you will almost certainly have problems:>If the characters recover Neverember's hoard and keep it for themselves, word gets out eventually.>Emissaries of the Harpers, the Lords' Alliance, and the Order of the Gauntlet come to the characters, asking that the gold be returned to Waterdeep. If the characters refuse to give it up, they are stripped of any memberships they might hold in these factions and quickly find themselves in political hot water. The Lords of Waterdeep charge them with the crime of robbery against the city. The characters face up to 1 month of hard labor plus damages equal to the value of the stolen currency plus 500gp. If they try to flee the city, the City Guard apprehends and imprisons them. If they somehow evade the local authorities, the Harpers and agents of the Lords' Alliance pursue them tirelessly.
Note that the robbery charge would be per PC, so they'd imprison you for 500k gold each, technically.
Note also that if you're Zhentarim, Emerald Enclave, Bregan D'aerthe, or generally a faction that wouldn't be associated with Waterdeep that much (Harpers are Harpers, Order of the Gauntlet are all LG types, and the Lords' Alliance is led by Waterdeep), you won't lose your faction memberships. But keeping gold stolen from Waterdeep and staying in Waterdeep are mutually exclusive. If you want your story to be thieves on the run from the law, you can absolutely set things up that way. IF, of course, you accept that good-aligned individuals will most likely be chasing you for it.
And assuming you can find a way to get 500k gold out of Waterdeep anyway at 5th level, short of bags of holding or a portable hole.