I like to think one can compose music, songs, jingles, etc. without "formal" training, but ...
There is so much to each of the arts that it takes a mysterious and marvelous mental and emotional facilities to produce a decent creation (that has anything extra above the commonplace work) in any art. This includes music. There is always a possibility of genius so there is no telling when and where it will appear. You might have it, or it could just pop up as you begin to "do" music.
Training, schooling, and studying on your own are always helpful, though. And then practice, practice, practice, is usually needed, and can become a fun part of your life.
Being in a school setting (for the arts) gives you a better chance, however, for many reasons. First is learning the discipline you will almost surely need. Then there is being with others, interacting with them, and being inspired by what you see and hear, and developing your tastes of what to try and what to avoid.
You will be exposed to working with others and seeing what you can easily do to work with them, and discover areas you will have to study and develop for your own work. You may get chances to do things you need materials and help to try and understand.
For example, I played the piano, but got the chance to (some would say "had to") play trumpet, violin, guitar, clarinet, flute, and some other "things," all of them not very well. Without having to commit to any of these instruments, I still learned about them and what they are capable of. It is a great help (or was to me) to feel comfortable about writing for them.
So, depending on how well you can soak up experience on your own, I'd still suggest you sample some formal training in a music education setting. I was in a university that had a conservatory so I could take Music School courses while I was still a major in mathematics and philosophy. I feel like it saved me ten years of study on my own in one year of study in the conservatory.
Good luck to you, whatever you do, and enjoy the music!