I believe .epub and .mobi files both don't support annotations. Which is unfortunate since they are some of the most popular formats. It looks like Kindle supports adding notes to ebooks but they are stored separately from the ebook file itself and I'm a big believer in 'the truth is in the file'. PDFs allow annotations but they don't reflow like most ebook file formats.
This question is slightly different from the one I listed below in my comment because that question is asking about a note file format and I'm asking about an ebook file format.
To annotate inside an ebook would require the file to be altered on the device side and some sites will not allow this due to the DRM they add. That said this is why Kindle creates a secondary file instead of in the ebook itself. This would also depend on the app you are using to view the ebook on.
The KDE linux program Okular has the ability to store annotations inside PDF files:
By default, Okular saves annotations in the local data directory for each user. Since KDE 4.9, it's optionally possible to store them directly in a PDF file by choosing "File -> Save As...", so they can be seen in other PDF viewers.
Note that this feature requires Poppler 0.20 or newer for regular PDF documents. If the PDF document you are annotating is encrypted, this feature requires Poppler 0.22 or newer.
It also has the ability to archive a document along with metadata (i.e. annotations) into an Okular-specific archive format:
Since KDE 4.2, Okular has the "document archiving" feature. This is an Okular-specific format for carrying the document plus various metadata related to it (currently only annotations).
You can save a "document archive" from the open document by choosing "File -> Export As -> Document Archive".
To open an Okular document archive, just open it with Okular as it would be eg a PDF document.