Linear representations of certain amalgamated products