The Rama (a”h) addresses this question in his glosses to the Shulchan Aruch, and he rules that it is permissible to wear a handkerchief on Shabbat, provided that it is attached to the garment. Meaning, one may not simply place the handkerchief in his suit pocket – even in a decorative manner – and then walk outside on Shabbat. He may wear it outside only if it is sewn to the suit. The reason for this distinction is that if the handkerchief is sewn to one’s garment, then it loses its independent identity and becomes part of the garment. If it is not attached to the garment, then it remains separate from the garment, and one will thus be considered carrying it through the public domain.
Ha’Rav Bentzion Abba Shaul (a”h), however, noted that the Rama’s ruling does not apply to modern-day handkerchiefs, which are considered “Chashuv”. The handkerchiefs used in the time of the Rama were of a much lower quality than the ones used in modern times and they therefore could be considered part of the garment to which they are attached.
The handkerchiefs used today are of a higher quality and therefore do not lose their independent status even when they are attached to a garment. Therefore, nowadays it is forbidden to wear a handkerchief on Shabbat in a place without an Eruv under all circumstances, even if it is attached to a garment.