Well, that’s typically up to you. While the pokédex network will automatically register that you’ve encountered an unidentified pokémon if you try to scan it with your own, you technically don’t have to do anything. However, the Pokémon Symposium thoroughly encourages you to contact your nearest pokémon professor so they may do a few initial observations or instruct you on how to take notes yourself. This can be as simple as a five-minute videophone call to whomever gave you your current pokédex.
Otherwise, under most circumstances, you would get to keep it. Really, the only times you wouldn’t is if it posed a very clear threat to you somehow (which is extremely rare but still a possibility outlined in the Symposium guidelines for discovery procedures) or if it was a legendary (at which point you may be asked politely but firmly to put it back where you found it, depending on the professor).