The simplest way is to run File > New... > Module Development > Action which creates an action for you and registers it in your layer.xml.
You can also declare your action in your layer manually:
<folder name="Loaders">
<folder name="text">
<folder name="html">
<folder name="Actions">
<file name="org-mymodule-MyAction.instance"/>
</folder>
</folder>
</folder>
</folder>
You can replace text/html with text/x-java, text/x-ant+xml, text/x-jsp, image/png, etc.
However, this still may not work depending on how the data loader for the type works. The DataLoader implementation has to override actionsContext() and return this path if it wants to load the Action instances from there. If the data loader you are interested in does not yet do this, please first file a bug report to make sure this is fixed in a future release; as an inferior workaround, you can use e.g.
DataLoader loader = DataLoaderPool.getDefault().firstProducerOf(SomeDataObject.class);
if (loader != null) {
SystemAction[] actions = loader.getActions();
SystemAction[] newactions = new SystemAction[actions.length + 2];
System.arraycopy(actions, 0, newactions, 0, actions.length);
// More realistically: take care that it is not a duplicate,
// place into a specific position, etc.:
newactions[actions.length] = null;
newactions[actions.length + 1] = SystemAction.get(SomeAction.class);
loader.setActions(newactions);
}
You need to know the implementation class of the foreign data object to implement this workaround. You should avoid doing this unless it is really critical to usability, and replace it with layer-based declarative actions as soon as that is available (you did file that bug report, right?).