In fact, in this case, the asteroid was detected independently by the SONEAR survey in Brazil and the ASAS-SN telescope network run by Ohio State University. Neither of these would fall under the "jurisdiction" of NASA or any governmental organization that would effectively be able to prevent them from talking about it. ASAS-SN tweeted the discovery, and I'm quite sure they didn't have to ask anyone permission to do so.
Secondly, the first few observations of a newly-discovered near-Earth object are generally not enough information to calculate the object's orbit accurately enough to know if it will hit Earth or not. So what do scientists do when they discover one? They immediately report it to the IAU and get the word out to as many other astronomers as possible, in order to obtain more observations & accurately determine the orbit.
As a result, it's hard to imagine how such a discovery could be kept secret.
Not necessarily. Only a couple people knew about this one before it had whizzed by. While I agree it'd be impossible to keep an upcoming impact secret, if the timeframe is short enough it would only take a few select people to keep it contained long enough to no longer matter.
And choosing to keep it secret wouldn't only be done if collision was known to be certain. Just having a moderate chance of impact might be enough.