God created everything (Gen 1.1). If sin exists, God created it . The question really should be then Why did God create sin?" To say that God did not create sin is to say that either the devil did when he rebelled against God or Adam did when he disobeyed God. Can the devil create something God did not? (it is common Christian belief that the devil cannot create something that God did not) If so then God would not be all powerful because one of His created beings created something that did not exist as something created by God (common Christian belief in God's attribute of Omnipotence).
What about Adam? If sin did not exist before Adam disobeyed then Adam created sin through his act of disobedience. Again, sin would have been created by one of God's created beings and again that would mean that God is not omnipotent because another being created something God did not. The act of creation is an act of omnipotence. Omnipotence is only attributed to God not to any of His created beings. Therefore, if sin exists God created it **Gen. 2:9. God created the Tree of Life and the Tree of the Knowledge of Good and Evil. Life pre-existed Adam, and Good and Evil pre-existed Adam. Who created Life? God. Who created Good? God. Who created Evil? The logical answer following this line of questioning/reasoning should lead one to conclude that God created evil. Further, in Gen 3:21 it states that Adam acquired the knowledge that God had of Good and Evil. Knowledge of a thing necessitates that the thing that is known exists. If it does not exist, it cannot be known. As the Tree of the Knowledge of Good and Evil existed before Adam fell, this knowledge was acquired when he fell.
Addressing evil (sin) it existed before Adam. Consider the lie (sin) told by the serpent to Eve before she took of the Tree of Knowledge of Good and Evil Gen. 3:4. The Bible clearly shows that sin existed before Adam. Who then created it? Did Lucifer? Did he do so when he as an angel rebelled against God? Isa 14:12-14. The angels were created free-will being just as Adam was. To have free-will implies having a choice between at least two options. One cannot have free-will with only one option. The angel Lucifer chose one of at least two options - to obey God [good] or disobey/rebel against God [evil]. He chose to rebel against God. He could not choose something that did not already exist. If we say that evil came into existence as a result of his rebellion, then we must also say that he or at least his act created something that God did not. This leads back to the opening statements of my submission above. That is, something that God did not create came into being through the direct will or act of one of God's created beings. Then God would not be omnipotent because someone else created something that God did not. We as Christians would not accept that God is not omnipotent).**
The fact that free will is exercised by God means that a choice exists. A choice between what is contrary to God and what is not contrary to God. If there is no choice to be made then there would be no need for free will. God's free will existed before the creation of the devil and Adam. Therefore, what is contrary to God (sin) and what is not contrary to God existed before the devil and Adam so neither of these created beings could be the creator of sin. The fact that God exercises free will means that a choice exists for God. God does not sin because it is impossible for Him to sin but because He chooses not to sin. Can God make a choice contrary to Himself? Only if He truly has a free will which He does. But because God is Holy, He would not (free-will) choose contrary to Himself. It would only be impossible for God to choose contrary to Himself if He did not have a free will because there would would be nothing to choose between "good - contrary" or "evil - not contrary". Only "good - not contrary" would exist therefore free will would not exist neither would sin exist. We can readily observe that this is not the case.
The existence of free will means the existence of choice which means the existence of "good -** not contrary to God" and "evil - contrary to God". This same choice existed for the devil and Adam. For Adam this is manifest in the existence before he was created of the Tree of the knowledge of good (what is not contrary to God) and evil (what is contrary to God). Exercising free will Adam chose evil. How can he choose something that does not already exist? If it already exists, who created it? Is the devil a creator? No, the devil exercising free will as an angel chose "contrary to God" which had to already exist. The question should be asked, why did God create sin.
In answer to the question posed "Does God have the capacity to sin, can God sin?" God has the capacity to do anything because one of His attributes is that is is omnipotent. Therefore, God has the capacity to sin, God can sin. However, because God also has the attribute of holiness, and He also has a free-will, He CHOOSES not to sin because He chooses not to violate His holiness. In other words, because He is omnipotent, He says "I can", and because He is holy He says "I won't".