Is there a way to be able to declare VLAN interfaces in Linux level and these somehow to be reachable from another instance in the same AWS subnet? I know that the underlay is not a real L2, but L3, so by default this does not work.
But is there a way? We just need this to test specific custom software that uses VLANs, so there is no other option for us, we need to find a way. I am not sure if there would be somehow in AWS the possibility to terminate the VLAN, through a tunnel or something to pass the L2 frame on the other side and then up to the dest instance's VLAN interface?
VLANs are not natively supported by VPCs. The technical fact is, IMHO, that VLANs are the underlying technology for VPCs itself (although not specified by AWS, but it makes sense if they would use VLAN or some custom, similar variant).
VLAN packets are dropped as soon as they are handled by the VPC, but they are still being handled inside the linux kernel. Unfortunately there doesn't exist any technology beside ethernet that transports VLANs (VPNs do not support it to my knowledge).
If you need to test software that relies on VLANs the only solution would be to create a large EC2 Bare Metal (!) Instance and install your favourite VM software on it. VMWare claims VLAN support, hopefully it fits your use case.
Then create multiple VMs on the same EC2 Bare Metal Instance and test your software inside a single EC2.