The Playstore holds a bunch of widgets to turn things on and off. So my suggestion might be "taking a truck to buy a bottle of beer", but it includes solutions for far more (similar and other) tasks in the future:
I use Tasker for a lot of "simple", but also for more complex jobs. Tasker is not only "a", but most likely "the" automation solution on Android. With this app, you combine "conditions" (triggers) with "tasks" (what should be done), and both cover a wide variety of things. Concentrating on your current question, you could create a simple task:
Audio Settings → Silent Mode, "On"
Then on your homescreen, select to add a shortcut, select "Tasker", select that Task. There you go.
But you could go even further, making that a full-fledged profile. I can think of multiple different triggers proving useful here:
- Event → Sensor → Shake, select a pattern (e.g. left-right) and duration (e.g. 2 sec).
- time-based (silence it at night)
- location based (silence it at work; based on GPS, network location, WiFi network near, cells near)
- incoming phone calls from people you want to ignore
- button presses (e.g. long-press on search button)
- battery level
These are just a few examples, a ton of addons offer even more (including voice-control). Chose from the above (or even combine triggers), and assign above created task to it.
Selected Tasker screenshots: Profiles, a task, categories (source: Google Play; click images for larger variants)
I have to admit, Tasker is not coming "cheap" (about US$ 4 currently). But it's worth every cent; I couldn't do without it anymore. A free 7-day-trial is available on its homepage; and when you export all its settings on day 6, then uninstall, re-install, and re-import the settings, you get another 7 days (no bad trick – argument from the dev himself). And over on Android.SE, you will find good help on this app (a good starter is the Tasker tag-wiki, and the questions using this tag). Some days I get the feeling almost every second issue we get at Android.SE can be answered with "Use Tasker" :)