Absolutely! Posting self-answered questions is encouraged and there is even a built-in provision to simplify doing it. Just don't fill up the site with trivial stuff. And if you start posting tons of threads that are useful only to you, people may get annoyed (it's happened). But if you have had a serious question, yourself, and found the solution, and it may benefit others, by all means, post it. Do a quick site search, though, to make sure the question hasn't already been asked. If it has, and someone else hasn't already posted the solution you found, post your answer on that question.
For a self-answered question, post the question as you would if you didn't already know the answer. There's nothing wrong, though, with ending it with an alert that it's a self-answered question just for context when people come across it.
In the Ask Question window, you'll see a checkbox near the bottom to indicate that you will be answering your own question. Clicking that opens an Answer edit window, as well. You can then work on both the question and answer, then post them both at the same time. That avoids helpful people jumping in with an answer for you before they see that it has already been solved.
Don't be surprised if you get additional answers. You may even learn an alternate solution. If you think your own solution is the best, you can accept your own answer two days after the question was posted.
In terms of rep, you obviously can't vote for your own posts, and you don't get rep for accepting your own answer. But a self-answered question provides two posts that other people can vote on. Just make them high-quality, useful posts.