Can the referees publish an article in the journal they review or the editorial board members publish an article in their journal? Is it ethical? Can you give examples for my question? Your answers are quite important for my research.
Your question is really two: reviewers and editorial board members.
Reviewers are peers reviewing other peers papers, or put differently and in very general terms, everyone reviews each other's manuscripts. Reviewers are not a professional occupation tied to a journal. This means that a reviewer is just as much welcome as an author as the author who was reviewed.
When it comes to editorial board members they are (of course with a few exceptions in a few, probably wealthy, journals) also scientists just like anyone submitting to the journal. They are as such not prohibited to submit manuscripts to the journal in which they serve. It is of course important that the editor's manuscript is edited by someone else. Even this may seem poor to many but if one takes an opposite stance and view it from the journal's side, having editors sneaking in papers at will will not reflect well on the journal so for no other reason, self preservation keeps most from doing so.
As an editor for a journal I would be very hesitant to submit to "my" journal but at the same time, if the field is narrow and possible publications venues are few then the choices may not be overwhelming and publishing in the "own" journal may be the only possibility. It is not fair to think of editors as pariah and person's who should be banned from communicating their science. It is just important that they can and that it is done in such a way that they receive the same treatment as any other submitting author.
Speaking as an editor: one of the reasons that many journals have a large pool of associate editors (in addition to spreading the load), is to avoid disqualifying editors from publishing. This is particularly important for field-specific journals with all-volunteer editing, as otherwise you would lose some of the important contributors and also discourage people from being willing to be editors. Most good journal software supports this by blinding an editor to any operations involving papers on which they have a conflict of interest, which automatically includes their own. Now, it is much more tricky for a chief editor to publish fairly: even then it may be handled appropriately if there is more than one chief editor, but should be very rare in order to avoid the appearance of impropriety.
You will find that the pool of reviewers for many journals comes from its recent submitters. I have often gotten a review request from an editor shortly after submitting an article of my own. It's very common and not unethical. Peer review is driven by this back and forth between reviewers and submitters.