Preamble: On the "World of Sin"
The "World of Sin" isn't a concept that pre-dates Jesus' words in John, and so we should be careful to not read this into the text too quickly. For the most part this is a later Christian concept (which can match up fairly well with many of the word's uses in John and later texts), which is primarily derived from later passages such as Ephesians 2:
“You once walked, following the course of this world, following the prince of the power of the air, the spirit that is now at work in the sons of disobedience — among whom we all once lived in the passions of our flesh”
Many Christians down the ages (at least since Thomas Aquinas' Summa Theologica, 13th Century) teach that the enemies of Christ are these three above - the world, the devil and the flesh - and so the word is assumed to always have negative connotations like those the OP has described.
'Kόσμος' in John
However, to understand this word (κόσμος) in context, we're better considering John's use of the word throughout the wider text. The author uses the word far more often than any of the other Gospels combined:
Matthew: 9 uses --- Mark: 3 uses --- Luke: 3 uses --- John: 79 uses
These 79 uses include a mixture of clearly positive (e.g. 3:16,17, 6:33, 11:9) and negative (e.g. 15:8, 16:33, 17:14) uses, so we should be careful to not type-cast its use too quickly. Whilst the word is often used to describe an opposing force to Jesus, this sense doesn't seem to be present in John 17:5.
Let us then consider the most common senses of the word as given by the NAS New Testament Lexicon:
- an apt and harmonious arrangement or constitution, order, government
- ornament, decoration, adornment, i.e. the arrangement of the stars, 'the heavenly hosts', as the ornament of the heavens. 1 Pet. 3:
- the world, the universe
- the circle of the earth, the earth
- the inhabitants of the earth, men, the human family
- the ungodly multitude; the whole mass of men alienated from God, and therefore hostile to the cause of Christ
- world affairs, the aggregate of things earthly: the whole circle of earthly goods, endowments riches, advantages, pleasures, etc, which although hollow and frail and fleeting, stir desire, seduce from God and are obstacles to the cause of Christ
- any aggregate or general collection of particulars of any sort:
a. the Gentiles as contrasted to the Jews (Rom. 11:12 etc)
b. of believers only, John 1:29; 3:16; 3:17; 6:33; 12:47 1 Cor. 4:9; 2 Cor. 5:19
Given that our word is used frequently by the author and in a variety of senses and contexts throughout the Gospel of John, we're best not automatically porting any of these senses in unduly. Whilst there are secondary metaphorical senses available to us, the simplest reading of the text would be to take the word at face value, considering its most primary senses first.
Considering the phrase "the glory I had with you before the κόσμος began", this makes perfect sense with each of the most primary definitions we have for the word, and so taking it to mean 'the beginning of the universe' as per the OP's first suggestion is a good approach to take for this passage.