For millennia, yoga practitioners have used a simple and effective method of overcoming negative thoughts called pratipaksha bhavana. The literal meaning is "opposite cultivation," and that tells you most of what you need to know about the practice.
In Chapter 2, verse 33 of the Yoga Sutras, Patanjali counsels that when we are disturbed by dubious thoughts, we should cultivate opposite ones. This verse comes just after the yamas and niyamas are listed, so we can assume that by dubious or negative thoughts, he means those that violate these yogic standards. (Examples: thoughts of violence, lying, stealing, promiscuity, and venality)
vitarka = negative thought
bhadane = when disturbed by
partipaksha = opposite thoughts
bhavana = should be cultivated
According to Patanjali, negative thoughts must be avoided because they keep us in ignorance (a state of disconnection from our True Self characterized by a belief in separation) and prolong our suffering. (Verse 34)
By telling us to cultivate opposite thoughts, Patanjali makes it clear that we should not waste time rationalizing our negative thoughts, or constructing justification stories around why we have such thoughts. And he does not advise us to suppress the thoughts. He speaks in terms of transformation.
How can we do this? Here are a few ways to begin supporting positive thoughts:
Change your environment (go somewhere calm, peaceful, beautiful)
Read, listen to, or watch something uplifting
Recognize the consequences of continuing with the negative thought (separation, ignorance and suffering)
What you focus on gets bigger. If you withdraw your energy from negative thought patterns and focus it on uplifting thoughts, the negative thoughts will start to weaken and evaporate over time. Your new focus, the positive thought, will begin to assert itself in place of the negative. If practiced to perfection, pratipaksha bhavana results in the eradication of negative thought.
What are some examples of opposite thoughts? Think of something that makes you:
happy: a friend/loved one; the beauty of nature; your pet; a favourite activity or memory
grateful: your breath; your last good meal; the capacity to forgive; the creativity of the human mind
humble: the vastness of the universe; the perfection of a snowflake; the aspiration of saints and avatars
Of course, there are countless other positive thoughts to cultivate: try working with beauty, elegance, excellence, grace, dignity, etc.