Depends on your state laws, whistles are not illegal in Pennsylvania, only sirens are illegal. See code below.
Chapter 35 - SPECIAL VEHICLES AND PEDESTRIANS
Subchapter A - Operation of Pedalcycles (Bicycles)
Section 3507. Lamps or other equipment on pedalcycles.
b) Audible signal devices. - A pedalcycle may be equipped with a device capable of giving a signal audible for a distance of at least 100 feet except that a pedalcycle shall not be equipped with nor shall any person use upon a pedalcycle any siren.